[Zope-CVS] CVS: Products/AdaptableStorage/serial_ofs - FilePData.py:1.3 FolderItems.py:1.10 FolderItemsByKeychain.py:1.3 IdAttribute.py:1.4 OFSProperties.py:1.2
Shane Hathaway
shane@zope.com
Mon, 6 Jan 2003 10:37:23 -0500
Update of /cvs-repository/Products/AdaptableStorage/serial_ofs
In directory cvs.zope.org:/tmp/cvs-serv31552/serial_ofs
Modified Files:
FilePData.py FolderItems.py FolderItemsByKeychain.py
IdAttribute.py OFSProperties.py
Log Message:
Added OptionalAspect, a wrapper that disables an aspect if it can't
serialize the object. This involved refactoring the IAspectSerializer
and IObjectSerializer interfaces. Thanks, Christian, for discovering
the need for this.
=== Products/AdaptableStorage/serial_ofs/FilePData.py 1.2 => 1.3 ===
--- Products/AdaptableStorage/serial_ofs/FilePData.py:1.2 Tue Dec 31 16:47:50 2002
+++ Products/AdaptableStorage/serial_ofs/FilePData.py Mon Jan 6 10:36:50 2003
@@ -18,6 +18,8 @@
from types import StringType
+from OFS.Image import File
+
from mapper_public import IAspectSerializer, FieldSchema
@@ -28,6 +30,9 @@
def getSchema(self):
return self.schema
+
+ def canSerialize(self, object):
+ return isinstance(object, File)
def serialize(self, object, event):
event.notifySerialized('data', object.data, 1)
=== Products/AdaptableStorage/serial_ofs/FolderItems.py 1.9 => 1.10 ===
--- Products/AdaptableStorage/serial_ofs/FolderItems.py:1.9 Tue Dec 31 16:47:50 2002
+++ Products/AdaptableStorage/serial_ofs/FolderItems.py Mon Jan 6 10:36:50 2003
@@ -37,6 +37,9 @@
def getSchema(self):
return self.schema
+ def canSerialize(self, object):
+ return isinstance(object, ObjectManager)
+
def serialize(self, object, event):
assert isinstance(object, ObjectManager), repr(object)
state = []
=== Products/AdaptableStorage/serial_ofs/FolderItemsByKeychain.py 1.2 => 1.3 ===
--- Products/AdaptableStorage/serial_ofs/FolderItemsByKeychain.py:1.2 Tue Dec 31 16:47:50 2002
+++ Products/AdaptableStorage/serial_ofs/FolderItemsByKeychain.py Mon Jan 6 10:36:50 2003
@@ -37,6 +37,9 @@
def getSchema(self):
return self.schema
+ def canSerialize(self, object):
+ return isinstance(object, ObjectManager)
+
def serialize(self, object, event):
assert isinstance(object, ObjectManager), repr(object)
state = []
=== Products/AdaptableStorage/serial_ofs/IdAttribute.py 1.3 => 1.4 ===
--- Products/AdaptableStorage/serial_ofs/IdAttribute.py:1.3 Tue Dec 31 16:47:50 2002
+++ Products/AdaptableStorage/serial_ofs/IdAttribute.py Mon Jan 6 10:36:50 2003
@@ -29,6 +29,9 @@
def getSchema(self):
return self.schema
+ def canSerialize(self, object):
+ return 1
+
def getAttrNameFor(self, object):
if isinstance(object, Item_w__name__):
return '__name__'
=== Products/AdaptableStorage/serial_ofs/OFSProperties.py 1.1 => 1.2 ===
--- Products/AdaptableStorage/serial_ofs/OFSProperties.py:1.1 Fri Jan 3 17:04:22 2003
+++ Products/AdaptableStorage/serial_ofs/OFSProperties.py Mon Jan 6 10:36:50 2003
@@ -20,6 +20,8 @@
from mapper_public import IAspectSerializer, RowSequenceSchema
+from OFS.PropertyManager import PropertyManager
+
string_repr_types = {
'string': 1,
@@ -45,8 +47,12 @@
def getSchema(self):
return self.schema
+ def canSerialize(self, object):
+ return isinstance(object, PropertyManager)
+
def serialize(self, object, event):
res = []
+ assert isinstance(object, PropertyManager), repr(object)
assert object._properties is object._propertyMap()
event.ignoreAttribute('_properties')
for p in object._properties:
@@ -64,6 +70,7 @@
return res
def deserialize(self, object, event, state):
+ assert isinstance(object, PropertyManager)
assert object._properties is object._propertyMap()
old_props = object.propdict()
new_props = {}