[Zope-CVS] CVS: Products/AdaptableStorage/mapper_std - AnyObjectSerializer.py:1.2

Shane Hathaway shane@zope.com
Fri, 21 Feb 2003 11:08:40 -0500


Update of /cvs-repository/Products/AdaptableStorage/mapper_std
In directory cvs.zope.org:/tmp/cvs-serv5192/mapper_std

Modified Files:
	AnyObjectSerializer.py 
Log Message:
- Fixed storage and loading of ZClass instances.
IObjectSerializer.createEmptyInstance() now accepts an optional
class_loader.  ASConnection provides a class loader that can load
ZClasses.

- Simplified configuration of mappers using "base" mappers.  Derived
mappers and gateways start with the configuration of the base mapper.

- Enhanced the configurability of ObjectGateways and
ObjectSerializers: there are now removeGateway() and removeAspect()
methods.


=== Products/AdaptableStorage/mapper_std/AnyObjectSerializer.py 1.1 => 1.2 ===
--- Products/AdaptableStorage/mapper_std/AnyObjectSerializer.py:1.1	Tue Dec 31 16:47:47 2002
+++ Products/AdaptableStorage/mapper_std/AnyObjectSerializer.py	Fri Feb 21 11:08:09 2003
@@ -23,19 +23,22 @@
 
     __implements__ = ObjectSerializer.__implements__
 
-    def __init__(self):
-        self._aspects = []  # [(name, aspect)] -- Order matters.
+    def __init__(self, base=None):
+        self.init(base)
 
     def canSerialize(self, object):
         return 1
 
-    def createEmptyInstance(self, classification=None):
+    def createEmptyInstance(self, classification=None, class_factory=None):
         if classification is None:
             # This serializer can't do anything without the classification.
             return None
         cn = classification['class_name']
         module, name = cn.split(':', 1)
-        m = __import__(module, {}, {}, ('__doc__',))
-        c = getattr(m, name)
+        if class_factory is not None:
+            c = class_factory(module, name)
+        else:
+            m = __import__(module, {}, {}, ('__doc__',))
+            c = getattr(m, name)
         return c.__basicnew__()