[Zope-CVS] CVS: Products/Ape/lib/apelib/core - classifiers.py:1.1.8.5 interfaces.py:1.9.2.7 io.py:1.6.2.7 mapper.py:1.4.4.5

Shane Hathaway shane at zope.com
Tue Dec 23 00:53:06 EST 2003


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

Modified Files:
      Tag: ape-0_8-branch
	classifiers.py interfaces.py io.py mapper.py 
Log Message:
The PostgreSQL tests now pass.

Some minor changes to interfaces were necessary in order to 
find and call all database initializers.


=== Products/Ape/lib/apelib/core/classifiers.py 1.1.8.4 => 1.1.8.5 ===
--- Products/Ape/lib/apelib/core/classifiers.py:1.1.8.4	Sat Dec 20 02:31:04 2003
+++ Products/Ape/lib/apelib/core/classifiers.py	Tue Dec 23 00:52:35 2003
@@ -25,10 +25,11 @@
     """
 
     __implements__ = IConfigurableClassifier
+    gateway = None
 
     def __init__(self, gw):
         self._class_to_mapper = {}  # class name -> mapper_name
-        self._gw = gw
+        self.gateway = gw
 
     def register(self, condition, value, mapper_name):
         if condition == "class":
@@ -46,11 +47,8 @@
         return ({"class_name": class_name}, mapper_name)
 
     def classifyState(self, event):
-        classification, serial = self._gw.load(event)
+        classification, serial = self.gateway.load(event)
         class_name = classification["class_name"]
         mapper_name = self._class_to_mapper[class_name]
         return ({"class_name": class_name}, mapper_name)
-
-    def store(self, event, classification):
-        return self._gw.store(event, classification)
 


=== Products/Ape/lib/apelib/core/interfaces.py 1.9.2.6 => 1.9.2.7 ===
--- Products/Ape/lib/apelib/core/interfaces.py:1.9.2.6	Sat Dec 20 23:24:03 2003
+++ Products/Ape/lib/apelib/core/interfaces.py	Tue Dec 23 00:52:35 2003
@@ -377,6 +377,13 @@
     The keys in classifications are implementation-dependent.
     """
 
+    gateway = Attribute(__doc__="""The classification IGateway.
+
+    Classifiers load and store classifications using a gateway.  This
+    attribute allows the system to store the classification of an
+    object by calling gateway.store().
+    """)
+
     def classifyObject(event):
         """Returns a classification and mapper_name.
 
@@ -390,13 +397,8 @@
         event is an ILoadEvent without a mapper (since this method
         chooses the mapper).
 
-        May load the classification from storage.
-        """
-
-    def store(event, classification):
-        """Stores the classification of an object.
-
-        event is an IStoreEvent.
+        May load the classification from storage by calling
+        self.gateway.load().
         """
 
 
@@ -491,6 +493,8 @@
     classifier = Attribute(__doc__="The IClassifier")
 
     oid_gen = Attribute(__doc__="The IOIDGenerator")
+
+    initializers = Attribute(__doc__="A list of IDatabaseInitializers")
 
     def check():
         """Verifies the configuration is sane.


=== Products/Ape/lib/apelib/core/io.py 1.6.2.6 => 1.6.2.7 ===
--- Products/Ape/lib/apelib/core/io.py:1.6.2.6	Sat Dec 20 23:24:03 2003
+++ Products/Ape/lib/apelib/core/io.py	Tue Dec 23 00:52:35 2003
@@ -86,6 +86,8 @@
         for mapper in self.conf.mappers.values():
             for obj in mapper.initializers:
                 initializers[obj] = 1
+        for obj in self.conf.initializers:
+            initializers[obj] = 1
             
         # Now call them.
         event = DatabaseInitEvent(self.conn_map, clear_all)
@@ -109,8 +111,11 @@
         mapper = self.conf.mappers[classified_state.mapper_name]
         event = StoreEvent(self.conf, mapper, oid, self.conn_map,
                            classified_state.classification, is_new)
+        # Store the classification first
+        self.conf.classifier.gateway.store(
+            event, classified_state.classification)
+        # Store the state second
         new_hash = mapper.gateway.store(event, classified_state.state)
-        self.conf.classifier.store(event, classified_state.classification)
         return event, new_hash
 
     def getPollSources(self, oid):


=== Products/Ape/lib/apelib/core/mapper.py 1.4.4.4 => 1.4.4.5 ===
--- Products/Ape/lib/apelib/core/mapper.py:1.4.4.4	Sat Dec 20 23:24:03 2003
+++ Products/Ape/lib/apelib/core/mapper.py	Tue Dec 23 00:52:35 2003
@@ -37,9 +37,6 @@
 
     # IConfigurableMapper implementation
 
-    def addInitializer(self, obj):
-        self.initializers.append(obj)
-
     def check(self, my_name):
         s = self.serializer
         if s is None:
@@ -89,11 +86,13 @@
     mappers = None
     classifier = None
     oid_gen = None
+    initializers = None
 
     def __init__(self, mappers, classifier, oid_gen):
         self.mappers = mappers
         self.classifier = classifier
         self.oid_gen = oid_gen
+        self.initializers = []
 
     def check(self):
         for name, mapper in self.mappers.items():




More information about the Zope-CVS mailing list