[Zope-CVS] CVS: Products/AdaptableStorage/serial_std - ClassificationAspect.py:1.1 FixedPersistentMapping.py:1.2 RemainingState.py:1.2 public.py:1.2
Shane Hathaway
shane@zope.com
Wed, 4 Dec 2002 23:18:40 -0500
Update of /cvs-repository/Products/AdaptableStorage/serial_std
In directory cvs.zope.org:/tmp/cvs-serv26322/serial_std
Modified Files:
FixedPersistentMapping.py RemainingState.py public.py
Added Files:
ClassificationAspect.py
Log Message:
- Switched to use of the "remaining state" aspect, enabling storage of
any extra data found on ZODB objects. Fixed bugs related to this.
- Made sure Zope 2 objects store their classification.
- Modified the serialization event interface a little to allow more
control over automatic references. This needs work still.
- MetaTypeClassifier is now also an IAspectSerializer, making it
possible to delegate classification details to the classifier.
=== Added File Products/AdaptableStorage/serial_std/ClassificationAspect.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Aspect for storing object classification.
$Id: ClassificationAspect.py,v 1.1 2002/12/05 04:18:08 shane Exp $
"""
from serial_public import IAspectSerializer, RecordSchema
class ClassificationAspect:
"""Delegates to the classifier."""
__implements__ = IAspectSerializer
schema = RecordSchema()
schema.addColumn('classification', 'classification')
def getSchema(self):
return self.schema
def getImpl(self, event):
c = event.getObjectMapper().getClassifier()
assert IAspectSerializer.isImplementedBy(c)
return c
def serialize(self, object, event):
return self.getImpl(event).serialize(object, event)
def deserialize(self, object, event, state):
self.getImpl(event).deserialize(object, event, state)
=== Products/AdaptableStorage/serial_std/FixedPersistentMapping.py 1.1 => 1.2 ===
--- Products/AdaptableStorage/serial_std/FixedPersistentMapping.py:1.1 Wed Nov 27 13:37:07 2002
+++ Products/AdaptableStorage/serial_std/FixedPersistentMapping.py Wed Dec 4 23:18:08 2002
@@ -39,8 +39,7 @@
for name in names:
mapper_name, key = self.map[name]
subob = object[name]
- event.notifySerializedRef(name, subob,
- mapper_name=mapper_name, key=key)
+ event.notifySerializedRef(name, subob, 0, mapper_name, key)
# One of the two will work. ;-)
event.ignoreAttribute('data')
=== Products/AdaptableStorage/serial_std/RemainingState.py 1.1 => 1.2 ===
--- Products/AdaptableStorage/serial_std/RemainingState.py:1.1 Wed Nov 27 13:37:07 2002
+++ Products/AdaptableStorage/serial_std/RemainingState.py Wed Dec 4 23:18:08 2002
@@ -37,8 +37,10 @@
def serialize(self, object, event):
assert IFullSerializationEvent.isImplementedBy(event)
- state = object.__getstate__()
- assert isinstance(state, DictType)
+ state = object.__dict__.copy()
+ for key in state.keys():
+ if key.startswith('_v_'):
+ del state[key]
for attrname in event.getSerializedAttributeNames():
if state.has_key(attrname):
del state[attrname]
@@ -61,7 +63,8 @@
assert len(state) == 1
assert len(state[0]) == 1
data = state[0][0]
- assert data
+ if not data:
+ return
infile = StringIO(data)
u = Unpickler(infile)
=== Products/AdaptableStorage/serial_std/public.py 1.1 => 1.2 ===
--- Products/AdaptableStorage/serial_std/public.py:1.1 Wed Nov 27 13:37:07 2002
+++ Products/AdaptableStorage/serial_std/public.py Wed Dec 4 23:18:08 2002
@@ -16,6 +16,7 @@
$Id$
"""
+from ClassificationAspect import ClassificationAspect
from FixedPersistentMapping import FixedPersistentMapping
from FullState import FullState
from IgnoredAttribute import IgnoredAttribute