[Zope-CVS] CVS: Products/Ape/lib/apelib/core - io.py:1.4.2.3

Shane Hathaway shane@zope.com
Thu, 24 Jul 2003 21:59:15 -0400


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

Modified Files:
      Tag: ape-scan-branch
	io.py 
Log Message:
Closed a hole in the scanner.

Until now, if in some way a connection started using an OID without calling
storage.load(), the scanner would assume that the OID depends on no sources.
This could happen in a ZEO environment and it would result in objects not
getting scanned.  The solution was to give scanners the ability to get the
sources for an OID directly if necessary.  Also enhanced tests.

Periodic scanning now seems to be in good shape.


=== Products/Ape/lib/apelib/core/io.py 1.4.2.2 => 1.4.2.3 ===
--- Products/Ape/lib/apelib/core/io.py:1.4.2.2	Thu Jul 24 08:15:26 2003
+++ Products/Ape/lib/apelib/core/io.py	Thu Jul 24 21:58:41 2003
@@ -99,7 +99,7 @@
             initializer.init(event)
 
 
-    def load(self, keychain):
+    def classifyState(self, keychain):
         mapper = self._root_mapper
         mapper_names = []
         # Follow the keychain to find the right mapper.
@@ -112,6 +112,11 @@
             classification, sub_mapper_name = cfr.classifyState(event)
             mapper_names.append(sub_mapper_name)
             mapper = mapper.getSubMapper(sub_mapper_name)
+        return classification, mapper_names, mapper
+
+
+    def load(self, keychain):
+        classification, mapper_names, mapper = self.classifyState(keychain)
         event = LoadEvent(mapper, keychain, self._conn_map)
         state, hash_value = mapper.getGateway().load(event)
         cs = ClassifiedState(state, classification, mapper_names)
@@ -133,6 +138,12 @@
         return event, new_hash
 
 
+    def getSources(self, keychain):
+        classification, mapper_names, mapper = self.classifyState(keychain)
+        event = LoadEvent(mapper, keychain, self._conn_map)
+        return mapper.getGateway().getSources(event)
+
+
     def newKeychain(self):
         # Try to use the root keychain generator to make a keychain.
         kgen = self._root_mapper.getKeychainGenerator()
@@ -148,7 +159,7 @@
         self._kos = kos
 
 
-    def serialize(self, keychain, obj):
+    def classifyObject(self, obj, keychain):
         mapper = self._root_mapper
         mapper_names = []
         classification = None
@@ -167,6 +178,12 @@
             classification, sub_mapper_name = cfr.classifyObject(obj, keychain)
             mapper_names.append(sub_mapper_name)
             mapper = mapper.getSubMapper(sub_mapper_name)
+        return classification, mapper_names, mapper
+
+
+    def serialize(self, keychain, obj):
+        classification, mapper_names, mapper = self.classifyObject(
+            obj, keychain)
         # Now serialize.
         ser = mapper.getSerializer()
         event = SerializationEvent(self._kos, mapper, keychain, obj)
@@ -238,12 +255,12 @@
         return is_new
 
 
-    def exportObject(self, obj, keychain=None, deactivate_func=None):
+    def exportObject(self, src_obj, dest_keychain=None, deactivate_func=None):
         count = 0
-        if keychain is None:
-            keychain = (self.newKey(),)
-        self._register(keychain, obj)
-        todo = [(keychain, obj)]
+        if dest_keychain is None:
+            dest_keychain = (self.newKey(),)
+        self._register(dest_keychain, src_obj)
+        todo = [(dest_keychain, src_obj)]
         while todo:
             keychain, obj = todo.pop()
             event, classified_state = self.obj_io.serialize(keychain, obj)
@@ -258,13 +275,13 @@
                         todo.append((ext_keychain, ext_obj))
 
 
-    def importObject(self, keychain, obj=None, commit_func=None):
+    def importObject(self, src_keychain, dest_obj=None, commit_func=None):
         count = 0
-        if obj is None:
-            obj = self.getObject(keychain)
-        root_obj = obj
-        self._register(keychain, obj)
-        todo = [(keychain, obj)]
+        if dest_obj is None:
+            dest_obj = self.getObject(src_keychain)
+        root_obj = dest_obj
+        self._register(src_keychain, dest_obj)
+        todo = [(src_keychain, dest_obj)]
         while todo:
             keychain, obj = todo.pop()
             e, classified_state, hash_value = self.gw_io.load(keychain)