[Zope-CVS] CVS: Products/AdaptableStorage/zodb - ASConnection.py:1.5 ASStorage.py:1.5

Shane Hathaway shane@zope.com
Mon, 9 Dec 2002 10:57:25 -0500


Update of /cvs-repository/Products/AdaptableStorage/zodb
In directory cvs.zope.org:/tmp/cvs-serv29307/zodb

Modified Files:
	ASConnection.py ASStorage.py 
Log Message:
Tidying:

- Removed domain mapper, which has been folded into object mapper (as I had
  always hoped to do--yay!)

- Removed makeKey from various places, since it now has a less meaningful
  purpose

- Removed classifyObject() from serialization events since it now serves
  no purpose I can think of

- Removed commented code

- Removed IObjectGateway since it now defines nothing more than IGateway

- Switched the order of the arguments for classifyObject() to match the
  order of the other methods

- Corrected and added comments



=== Products/AdaptableStorage/zodb/ASConnection.py 1.4 => 1.5 ===
--- Products/AdaptableStorage/zodb/ASConnection.py:1.4	Sat Dec  7 00:59:14 2002
+++ Products/AdaptableStorage/zodb/ASConnection.py	Mon Dec  9 10:57:24 2002
@@ -53,15 +53,6 @@
             self._root_mapper = root_mapper
         return root_mapper
 
-##    def getOIDInfo(self, oid):
-##        keychain = self._db._oid_encoder.decode(oid)
-##        root_mapper = self._root_mapper
-##        if root_mapper is None:
-##            root_mapper = self._db._mapper_resource.access(self)
-##            self._root_mapper = root_mapper
-        
-##        return domain_mapper.getMapper(mapper_name), keychain
-
 
     def close(self):
         db = self._db
@@ -94,11 +85,8 @@
         mapper = self.getRootMapper()
         for mapper_name in mapper_names:
             mapper = mapper.getSubMapper(mapper_name)
-        object = mapper.getSerializer().createEmptyInstance()
-        if object is None:
-            state = unpickler.load()
-            object = mapper.getSerializer().createEmptyInstance(state)
-            assert object is not None
+        object = mapper.getSerializer().createEmptyInstance(classification)
+        assert object is not None
 
         object._p_oid=oid
         object._p_jar=self
@@ -124,7 +112,7 @@
             for mapper_name in mapper_names:
                 mapper = mapper.getSubMapper(mapper_name)
             ser = mapper.getSerializer()
-            
+
             object = ser.createEmptyInstance()
             if object is not None:
                 object._p_oid=oid
@@ -179,34 +167,6 @@
 
         stack=[object]
 
-        # Create a special persistent_id that passes T and the subobject
-        # stack along:
-        #
-        # def persistent_id(object,
-        #                   self=self,
-        #                   stackup=stackup, new_oid=self.new_oid):
-        #     if (not hasattr(object, '_p_oid') or
-        #         type(object) is ClassType): return None
-        #
-        #     oid=object._p_oid
-        #
-        #     if oid is None or object._p_jar is not self:
-        #         oid = self.new_oid()
-        #         object._p_jar=self
-        #         object._p_oid=oid
-        #         stackup(object)
-        #
-        #     klass=object.__class__
-        #
-        #     if klass is ExtensionKlass: return oid
-        #
-        #     if hasattr(klass, '__getinitargs__'): return oid
-        #
-        #     module=getattr(klass,'__module__','')
-        #     if module: klass=module, klass.__name__
-        #
-        #     return oid, klass
-
         file=StringIO()
         seek=file.seek
         pickler=Pickler(file,1)
@@ -266,19 +226,21 @@
                 oid_encoder = self._db._oid_encoder
                 classification = None
                 if keychain:
+                    # Use classification to discover what mapper to use
+                    # for storage.
                     # classify the parents.
                     for i in range(1, len(keychain)):
                         k = keychain[:i]
                         o = self[oid_encoder.encode(k)]
                         cfr = mapper.getClassifier()
                         classification, sub_mapper_name = \
-                                        cfr.classifyObject(k, o)
+                                        cfr.classifyObject(o, k)
                         mapper_names.append(sub_mapper_name)
                         mapper = mapper.getSubMapper(sub_mapper_name)
-                    # Now classify this object.
+                    # Now classify the object being stored.
                     cfr = mapper.getClassifier()
                     classification, sub_mapper_name = cfr.classifyObject(
-                        keychain, object)
+                        object, keychain)
                     mapper_names.append(sub_mapper_name)
                     mapper = mapper.getSubMapper(sub_mapper_name)
 
@@ -314,7 +276,6 @@
             # serial number for a newly created object
             try: cache[oid]=object
             except:
-                print 'YIKES!', `object.__dict__`, `cache[oid].__dict__`
                 # Dang, I bet its wrapped:
                 if hasattr(object, 'aq_base'):
                     cache[oid]=object.aq_base


=== Products/AdaptableStorage/zodb/ASStorage.py 1.4 => 1.5 ===
--- Products/AdaptableStorage/zodb/ASStorage.py:1.4	Sat Dec  7 00:59:14 2002
+++ Products/AdaptableStorage/zodb/ASStorage.py	Mon Dec  9 10:57:24 2002
@@ -66,13 +66,7 @@
     def _load(self, root_mapper, keychain):
         mapper = root_mapper
         mapper_names = []
-        # Follow the keychain to find the right mapper.  Every item in
-        # the keychain except the last one involves a change of
-        # domain.  So change mappers for
-        # keychain[:1], keychain[:2]... keychain[:len(keychain)-1].
-        # The last item in the keychain is for the use by the gateway.
-        # (In other words, we should expect there to be one more key
-        # than domain changes.)
+        # Follow the keychain to find the right mapper.
         classification = None
         for i in range(len(keychain)):
             k = keychain[:i + 1]