[Zope-CVS] CVS: Products/Ape/lib/apelib/core - classifiers.py:1.1.8.4 events.py:1.6.2.5 interfaces.py:1.9.2.5 io.py:1.6.2.5 mapper.py:1.4.4.3

Shane Hathaway shane at zope.com
Sat Dec 20 02:31:35 EST 2003


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

Modified Files:
      Tag: ape-0_8-branch
	classifiers.py events.py interfaces.py io.py mapper.py 
Log Message:
Continued refactoring and renaming.

Over 60 tests now pass.


=== Products/Ape/lib/apelib/core/classifiers.py 1.1.8.3 => 1.1.8.4 ===
--- Products/Ape/lib/apelib/core/classifiers.py:1.1.8.3	Fri Dec 19 21:52:47 2003
+++ Products/Ape/lib/apelib/core/classifiers.py	Sat Dec 20 02:31:04 2003
@@ -17,7 +17,7 @@
 """
 
 from apelib.core.interfaces import IConfigurableClassifier, IClassifier
-from apelib.core.interfaces import ClassificationError
+from apelib.core.interfaces import ClassificationError, ConfigurationError
 
 
 class SimpleClassifier:
@@ -36,17 +36,20 @@
         else:
             raise ConfigurationError("Unknown condition type: %s" % condition)
 
+    def setOption(self, mapper_name, option, value):
+        raise ConfigurationError("No options available")
+
     def classifyObject(self, event):
         c = event.obj.__class__
-        cname = "%s.%s" % (c.__module__, c.__name__)
-        mapper_name = self._class_to_mapper[cname]
-        return ({"class": cname}, mapper_name)
+        class_name = "%s.%s" % (c.__module__, c.__name__)
+        mapper_name = self._class_to_mapper[class_name]
+        return ({"class_name": class_name}, mapper_name)
 
     def classifyState(self, event):
         classification, serial = self._gw.load(event)
-        cname = classification["class"]
-        mapper_name = self._class_to_mapper[cname]
-        return ({"class": cname}, mapper_name)
+        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/events.py 1.6.2.4 => 1.6.2.5 ===
--- Products/Ape/lib/apelib/core/events.py:1.6.2.4	Fri Dec 19 21:52:47 2003
+++ Products/Ape/lib/apelib/core/events.py	Sat Dec 20 02:31:04 2003
@@ -168,7 +168,7 @@
         if isinstance(name_or_names, (str, unicode)):
             self._attrs[name_or_names] = 1
         else:
-            for name in names:
+            for name in name_or_names:
                 self._attrs[name] = 1
 
 


=== Products/Ape/lib/apelib/core/interfaces.py 1.9.2.4 => 1.9.2.5 ===
--- Products/Ape/lib/apelib/core/interfaces.py:1.9.2.4	Fri Dec 19 21:52:47 2003
+++ Products/Ape/lib/apelib/core/interfaces.py	Sat Dec 20 02:31:04 2003
@@ -78,6 +78,8 @@
 
         Used during serialization (storing/export).
         Returns None if the object is not in the object database.
+        Raises TypeError if the object can not be stored directly
+        in the database.
         """
 
     def new_oid():
@@ -325,6 +327,9 @@
         The hash value is either an integer or an object that is
         hashable using the Python hash() function.  The hashable
         object is used to detect storage conflicts.
+
+        If no data is available for the requested OID, load() should
+        raise a KeyError.
         """
 
     def store(event, data):
@@ -406,6 +411,20 @@
                       and 'folder_object'.
         """
 
+    def setOption(mapper_name, option, value):
+        """Sets a classification option pertaining to a particular mapper.
+
+        As an example, the zope2 classifier allows at least two options:
+
+        'default_extension' - specifies the filename extension to
+        generate if the object is being stored on the filesystem and
+        has no extension.
+
+        'content_type_attr' - The name of the object attribute that
+        specifies the MIME type of the object, for the purpose of
+        determining an appropriate default filename extension.
+        """
+
 
 class IOIDGenerator (Interface):
     """A utility for generating OIDs.
@@ -416,6 +435,8 @@
     through an IMapperEvent, allows OID knowledge to be kept in
     one place.
     """
+
+    #root_oid = Attribute(__doc__="The OID to use at the root")
 
     def new_oid(event, name, stored):
         """Returns a new oid.


=== Products/Ape/lib/apelib/core/io.py 1.6.2.4 => 1.6.2.5 ===
--- Products/Ape/lib/apelib/core/io.py:1.6.2.4	Fri Dec 19 21:52:47 2003
+++ Products/Ape/lib/apelib/core/io.py	Sat Dec 20 02:31:04 2003
@@ -99,7 +99,7 @@
         # Find all initializers, eliminating duplicates.
         initializers = {}  # obj -> 1
         for mapper in self.conf.mappers.values():
-            for obj in mapper.getInitializers():
+            for obj in mapper.initializers:
                 initializers[obj] = 1
             
         # Now call them.
@@ -113,7 +113,7 @@
         return self.conf.classifier.classifyState(event)
 
     def load(self, oid):
-        classification, mapper_names = self.classifyState(oid)
+        classification, mapper_name = self.classifyState(oid)
         mapper = self.conf.mappers[mapper_name]
         event = LoadEvent(self.conf, mapper, oid, self.conn_map, classification)
         state, hash_value = mapper.gateway.load(event)
@@ -125,7 +125,7 @@
         event = StoreEvent(self.conf, mapper, oid, self.conn_map,
                            classified_state.classification, overwrite)
         new_hash = mapper.gateway.store(event, classified_state.state)
-        self.conf.classifier.store(event, classification)
+        self.conf.classifier.store(event, classified_state.classification)
         return event, new_hash
 
     def getPollSources(self, oid):
@@ -163,7 +163,7 @@
     def deserialize(self, oid, obj, classified_state):
         mapper = self.conf.mappers[classified_state.mapper_name]
         event = DeserializationEvent(self.conf, mapper, oid, self.obj_db, obj)
-        mapper.serializer.deserialize(obj, event, classified_state.state)
+        mapper.serializer.deserialize(event, classified_state.state)
         return event
 
     def newObject(self, classified_state):
@@ -228,7 +228,7 @@
             count += 1
             if deactivate_func is not None:
                 deactivate_func(obj, count)
-            self.gw_io.store(oid, classified_state)
+            self.gw_io.store(oid, classified_state, False)
             ext_refs = event.external
             if ext_refs:
                 for ext_oid, ext_obj in ext_refs:


=== Products/Ape/lib/apelib/core/mapper.py 1.4.4.2 => 1.4.4.3 ===
--- Products/Ape/lib/apelib/core/mapper.py:1.4.4.2	Fri Dec 19 21:52:47 2003
+++ Products/Ape/lib/apelib/core/mapper.py	Sat Dec 20 02:31:04 2003
@@ -30,7 +30,7 @@
     gateway = None
     initializers = None
 
-    def __init__(self, serializer, gateway):
+    def __init__(self, serializer=None, gateway=None):
         self.serializer = serializer
         self.gateway = gateway
         self.initializers = []
@@ -56,10 +56,10 @@
         if not interfaces.IGateway.isImplementedBy(g):
             raise ConfigurationError(
                 'Mapper %s: Gateway is not an IGateway' % my_name)
-        if s.getSchema() != g.getSchema():
+        if s.schema != g.schema:
             # Try to show a descriptive error
-            ss = s.getSchema()
-            gs = g.getSchema()
+            ss = s.schema
+            gs = g.schema
             msg = None
             if isinstance(ss, DictType) and isinstance(gs, DictType):
                 for key in ss.keys():




More information about the Zope-CVS mailing list