[Zope-CVS] CVS: Products/AdaptableStorage/serial_ofs - FolderItemsByKeychain.py:1.1 FolderItems.py:1.8 public.py:1.2
Shane Hathaway
shane@zope.com
Tue, 10 Dec 2002 15:35:58 -0500
Update of /cvs-repository/Products/AdaptableStorage/serial_ofs
In directory cvs.zope.org:/tmp/cvs-serv9744/serial_ofs
Modified Files:
FolderItems.py public.py
Added Files:
FolderItemsByKeychain.py
Log Message:
Since the keychain is not stored by FolderItems, it doesn't need to be
passed back and forth. Simplified both FolderItems and FSDirectoryItems
by removing keychain from the schema, then added FolderItemsByKeychain
which *does* store the keychain.
=== Added File Products/AdaptableStorage/serial_ofs/FolderItemsByKeychain.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.
#
##############################################################################
"""Serializer for the items in an ObjectManager.
This version stores keychains.
$Id: FolderItemsByKeychain.py,v 1.1 2002/12/10 20:35:57 shane Exp $
"""
from Acquisition import aq_base
from OFS.ObjectManager import ObjectManager
from serial_public import IAspectSerializer, RowSequenceSchema
class FolderItemsByKeychain:
""" """
__implements__ = IAspectSerializer
__used_for__ = ObjectManager
schema = RowSequenceSchema()
schema.addField('id', 'string', 1)
schema.addField('keychain', 'keychain')
def getSchema(self):
return self.schema
def serialize(self, object, event):
assert isinstance(object, ObjectManager), repr(object)
state = []
event.ignoreAttribute('_objects')
for id, subob in object.objectItems():
base = aq_base(subob)
keychain = event.identifyObject(base)
if keychain is None:
keychain = event.makeKeychain(id, 1)
event.notifySerializedRef(id, base, 1, keychain)
state.append((id, keychain))
return state
def deserialize(self, object, event, state):
assert isinstance(object, ObjectManager)
for (id, keychain) in state:
subob = event.dereference(id, keychain)
setattr(object, id, subob)
object._objects += ({'id': id, 'meta_type':
subob.__class__.meta_type},)
=== Products/AdaptableStorage/serial_ofs/FolderItems.py 1.7 => 1.8 ===
--- Products/AdaptableStorage/serial_ofs/FolderItems.py:1.7 Mon Dec 9 17:11:07 2002
+++ Products/AdaptableStorage/serial_ofs/FolderItems.py Tue Dec 10 15:35:57 2002
@@ -13,6 +13,9 @@
##############################################################################
"""Serializer for the items in an ObjectManager.
+This version does not store keychains, but instead assumes they
+can be computed.
+
$Id$
"""
@@ -30,7 +33,6 @@
schema = RowSequenceSchema()
schema.addField('id', 'string', 1)
- schema.addField('keychain', 'keychain', 0)
def getSchema(self):
return self.schema
@@ -45,12 +47,13 @@
if keychain is None:
keychain = event.makeKeychain(id, 0)
event.notifySerializedRef(id, base, 1, keychain)
- state.append((id, keychain))
+ state.append((id,))
return state
def deserialize(self, object, event, state):
assert isinstance(object, ObjectManager)
- for id, keychain in state:
+ for (id,) in state:
+ keychain = event.makeKeychain(id, 0)
subob = event.dereference(id, keychain)
setattr(object, id, subob)
object._objects += ({'id': id, 'meta_type':
=== Products/AdaptableStorage/serial_ofs/public.py 1.1 => 1.2 ===
--- Products/AdaptableStorage/serial_ofs/public.py:1.1 Wed Nov 27 13:37:07 2002
+++ Products/AdaptableStorage/serial_ofs/public.py Tue Dec 10 15:35:57 2002
@@ -17,6 +17,7 @@
"""
from FolderItems import FolderItems
+from FolderItemsByKeychain import FolderItemsByKeychain
from IdAttribute import IdAttribute
from MetaTypeClassifier import MetaTypeClassifier