Florent Guillaume wrote:

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 

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 Fulton           mailto:[EMAIL PROTECTED]       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org
For more information about ZODB, see the ZODB Wiki:

ZODB-Dev mailing list  -  ZODB-Dev@zope.org

Reply via email to