[ZODB-Dev] Re: SVN: Zope3/branches/jim-adapter/src/zope/app/component/ Added compatibility for old pickles.

Jim Fulton jim at zope.com
Tue Apr 25 10:11:07 EDT 2006


Florent Guillaume wrote:
> Hi,
> 
> Jim Fulton wrote:
> 
>> Log message for revision 67595:
>>   Added compatibility for old pickles.
>>  
>> Modified: 
>> Zope3/branches/jim-adapter/src/zope/app/component/tests/test_registration.py 
>>
>> +# Work around a bug in ZODB
>> +# XXX fix ZODB
>> +class FileStorage(ZODB.FileStorage.FileStorage):
>> +    +    def new_oid(self):
>> +        self._lock_acquire()
>> +        try:
>> +            last = self._oid
>> +            d = ord(last[-1])
>> +            if d < 255:  # fast path for the usual case
>> +                last = last[:-1] + chr(d+1)
>> +            else:        # there's a carry out of the last byte
>> +                last_as_long, = _structunpack(">Q", last)
>> +                last = _structpack(">Q", last_as_long + 1)
>> +            self._oid = last
>> +            return last
>> +        finally:
>> +             self._lock_release()
>> + +
> 
> 
> What's the ZODB bug?

Because getting an object id doesn't modify the database.

> Why would new_oid be called for a readonly storage 
> (which the original code checks)?

Because DemoStorage needs to know what oid to start allocating new oids with.

It could be argued that DemoStorage should behave differently, but that's
another issue.

The ZODB APIs really need to be cleaned up.  In particular, we need a set of
carefully written and correct interfaces that describe the contracts.
There are lots of informal contracts between components that have
evolved over time and made things very brittle.  Things that should work together
don't.

Ironically, the original use case for DemoStorage was to allow running Zope from a
CD with a base database on a CD.  That now (afaict) know longer works.

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org


More information about the ZODB-Dev mailing list