[ZODB-Dev] Re: [Zope-Checkins] CVS: ZODB3/ZODB/FileStorage -fspack.py:1.3

Tim Peters tim at zope.com
Mon Jan 19 15:10:06 EST 2004


>> +        raise FileStorageError(
>> +            "The database has already been packed to a later time"
>> +            " or no changes have been made since the last pack")

[Toby Dickenson]
> In the past Ive found it counterproductive for applications to have
> to deal with this exception.
>
> If we want to leave FileStorage raising an exception in this case,
> perhaps DB.pack could catch and swallow a RedundantPackError?

How about you and Chris Withers work up a patch that makes you happy and
leaves his existing code working correctly?  For backward compatibility, I
bet it's unlikely to show up in future 3.1 or 3.2 releases, but 3.3 is still
in alpha so still has some flexibility.

I'm personally not keen on hiding exceptions by magic:  if I try to pack,
and pass arguments such that nothing actually changes, it's unclear whether
I made a mistake or don't care.  Raising an exception lets me take
appropriate action either way; hiding the exception leaves me clueless if I
actually made a mistake.  So I'd rather make RedundantPackError a subclass
of FileStorageError (then old code special-casing this particular flavor of
FileStorageError will continue to catch it); making it a subclass allows an
easier way to recognize it.

    try:
        whatever
    except RedundantPackError:
        pass  # if I don't care about this particular flavor
    except FileStorageError:
        panic # but I do care about other forms of FileStorageError

or

    try:
        whatever
    except FileStorageError:
        panic # if I care about all forms of FileStorageError




More information about the ZODB-Dev mailing list