[Zope-CVS] CVS: Products/Ape/lib/apelib/zodb3 - connection.py:1.6.2.4 consts.py:1.1.8.1 serializers.py:1.3.2.4 storage.py:1.8.2.2 gateways.py:NONE

Shane Hathaway shane at zope.com
Sat Dec 20 23:24:38 EST 2003


Update of /cvs-repository/Products/Ape/lib/apelib/zodb3
In directory cvs.zope.org:/tmp/cvs-serv18412/lib/apelib/zodb3

Modified Files:
      Tag: ape-0_8-branch
	connection.py consts.py serializers.py storage.py 
Removed Files:
      Tag: ape-0_8-branch
	gateways.py 
Log Message:
Continued cleanup after refactoring the interfaces.  See CHANGES.txt.

All tests now pass except for the SQL tests.



=== Products/Ape/lib/apelib/zodb3/connection.py 1.6.2.3 => 1.6.2.4 ===
--- Products/Ape/lib/apelib/zodb3/connection.py:1.6.2.3	Sat Dec 20 02:31:08 2003
+++ Products/Ape/lib/apelib/zodb3/connection.py	Sat Dec 20 23:24:06 2003
@@ -32,9 +32,9 @@
 from ZODB.ConflictResolution import ResolvedSerial
 from zLOG import LOG, ERROR
 
-from consts import ROOT_OID, HASH0, DEBUG
+from consts import HASH0, DEBUG
 from apelib.core.io import ObjectSystemIO, ClassifiedState
-from apelib.core.interfaces import IObjectDatabase
+from apelib.core.interfaces import IObjectDatabase, LoadError
 
 
 class ApeConnection (Connection):
@@ -68,11 +68,12 @@
 
 
     def _prepareRoot(self):
-        oid = ROOT_OID
+        osio = self.getObjectSystemIO()
+        oid = osio.conf.oid_gen.root_oid
         try:
             self[oid]
-        except KeyError:
-            # Create the root object..
+        except (KeyError, LoadError):
+            # Create the root object.
             from Persistence import PersistentMapping
             root = PersistentMapping()
             root._p_jar = self
@@ -85,6 +86,10 @@
             self.tpc_vote(t)
             self.tpc_finish(t)
 
+    def root(self):
+        osio = self.getObjectSystemIO()
+        oid = osio.conf.oid_gen.root_oid
+        return self[oid]
 
     def getObjectSystemIO(self):
         osio = self._osio
@@ -131,7 +136,8 @@
         obj._p_changed=None
 
         self._cache[oid] = obj
-        if oid=='\0\0\0\0\0\0\0\0':
+        
+        if oid == osio.conf.oid_gen.root_oid:
             self._root_=obj # keep a ref
         return obj
 


=== Products/Ape/lib/apelib/zodb3/consts.py 1.1 => 1.1.8.1 ===
--- Products/Ape/lib/apelib/zodb3/consts.py:1.1	Wed Apr  9 23:09:58 2003
+++ Products/Ape/lib/apelib/zodb3/consts.py	Sat Dec 20 23:24:06 2003
@@ -23,6 +23,5 @@
 else:
     DEBUG = 0
 
-ROOT_OID = '\0' * 8
 HASH0 = '\0' * 8
 HASH1 = '\0' * 7 + '\001'


=== Products/Ape/lib/apelib/zodb3/serializers.py 1.3.2.3 => 1.3.2.4 ===
--- Products/Ape/lib/apelib/zodb3/serializers.py:1.3.2.3	Sat Dec 20 02:31:08 2003
+++ Products/Ape/lib/apelib/zodb3/serializers.py	Sat Dec 20 23:24:06 2003
@@ -102,52 +102,6 @@
         event.obj.__init__(data)
 
 
-
-##class FixedPersistentMapping:
-##    """Unchanging persistent mapping.
-
-##    Generally used for a ZODB root object.
-##    """
-
-##    __implements__ = ISerializer
-##    schema = None  # No storage
-
-##    def __init__(self):
-##        # map: { name -> (oid, mapper) }
-##        self.map = {}
-
-##    def add(self, name, oid, mapper_name=None):
-##        self.map[name] = (oid, mapper_name)
-
-##    def canSerialize(self, obj):
-##        return isinstance(obj, PersistentMapping)
-
-##    def serialize(self, obj, event):
-##        names = obj.keys()
-##        names.sort()
-##        expected = self.map.keys()
-##        expected.sort()
-##        assert names == expected, '%s != %s' % (names, expected)
-##        for name in names:
-##            oid, mapper_name = self.map[name]
-##            subob = obj[name]
-##            event.referenced(name, subob, False, oid)
-##        event.ignore(('data', '_container'))
-
-##    def deserialize(self, obj, event, state):
-##        assert state is None
-##        data = {}
-##        for name, (oid, mapper_name) in self.map.items():
-##            subob = event.resolve(
-##                name, oid, {'mapper_name': mapper_name})
-##            data[name] = subob
-##        # The PersistentMapping doesn't have its data or _container
-##        # attribute yet, and we don't know what its name should be
-##        # since PersistentMapping's internal structure is not fixed.
-##        # So call the PersistentMapping's constructor.
-##        obj.__init__(data)
-
-
 class RollCall:
     """Helps ensure all parts of an object get serialized.
 


=== Products/Ape/lib/apelib/zodb3/storage.py 1.8.2.1 => 1.8.2.2 ===
--- Products/Ape/lib/apelib/zodb3/storage.py:1.8.2.1	Wed Dec 17 23:43:54 2003
+++ Products/Ape/lib/apelib/zodb3/storage.py	Sat Dec 20 23:24:06 2003
@@ -123,15 +123,12 @@
             if DEBUG:
                 print 'storing', `oid`, `h64`
             if h64 == HASH0:
-                # Writing a new object.  Ask the gateway not to
-                # overwrite existing data.
-                overwrite = False
+                # Writing a new object.
+                is_new = True
             else:
                 # Overwriting an old object.  Use the hash to verify
                 # that the new data was derived from the old data.
-                # If the test passes, allow the gateway to overwrite
-                # the existing data.
-                overwrite = True
+                is_new = False
                 event, old_cs, old_hash = self._gwio.load(oid)
                 old_h64 = self.hash64(old_hash)
                 if h64 != old_h64:
@@ -144,7 +141,7 @@
             file = StringIO(data)
             u = Unpickler(file)
             classified_state = u.load()
-            event, new_hash = self._gwio.store(oid, classified_state, overwrite)
+            event, new_hash = self._gwio.store(oid, classified_state, is_new)
             new_h64 = self.hash64(new_hash)
             if self._scanner is not None:
                 sources = event.mapper.gateway.getPollSources(event)

=== Removed File Products/Ape/lib/apelib/zodb3/gateways.py ===




More information about the Zope-CVS mailing list