[Zope-CVS] CVS: Products/AdaptableStorage/serial_std - FixedClassifier.py:1.1 FixedPersistentMapping.py:1.4 public.py:1.4
Shane Hathaway
shane@zope.com
Sat, 7 Dec 2002 00:59:44 -0500
Update of /cvs-repository/Products/AdaptableStorage/serial_std
In directory cvs.zope.org:/tmp/cvs-serv21888/serial_std
Modified Files:
FixedPersistentMapping.py public.py
Added Files:
FixedClassifier.py
Log Message:
Fixed the bugs in the new strategy (OIDs no longer include mapper_names,
allowing more flexibility in loading and storage). Did not resolve new
key generation yet, but everything else seems to be in good shape.
=== Added File Products/AdaptableStorage/serial_std/FixedClassifier.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.
#
##############################################################################
"""Fixed-key classification.
$Id: FixedClassifier.py,v 1.1 2002/12/07 05:59:14 shane Exp $
"""
import os
from serial_public import IClassifier, DeserializationError
class FixedClassifier:
__implements__ = IClassifier
def __init__(self):
self.key_to_res = {}
def register(self, key, mapper_name):
self.key_to_res[key] = ({}, mapper_name)
def classifyObject(self, keychain, value):
k = keychain[-1]
return self.key_to_res[k]
def classifyState(self, mapper, keychain):
k = keychain[-1]
return self.key_to_res[k]
def store(self, mapper, keychain, classification):
pass
=== Products/AdaptableStorage/serial_std/FixedPersistentMapping.py 1.3 => 1.4 ===
--- Products/AdaptableStorage/serial_std/FixedPersistentMapping.py:1.3 Fri Dec 6 17:06:51 2002
+++ Products/AdaptableStorage/serial_std/FixedPersistentMapping.py Sat Dec 7 00:59:14 2002
@@ -22,9 +22,12 @@
class FixedPersistentMapping:
__implements__ = IAspectSerializer
- def __init__(self, map):
- # map: { name -> keychain }
- self.map = map
+ def __init__(self):
+ # map: { name -> (keychain, mapper) }
+ self.map = {}
+
+ def add(self, name, keychain, mapper_names=None):
+ self.map[name] = (keychain, mapper_names)
def getSchema(self):
return None # No storage
@@ -37,7 +40,7 @@
assert names == expected, '%s != %s' % (names, expected)
for name in names:
- keychain = self.map[name]
+ keychain, mapper_names = self.map[name]
subob = object[name]
event.notifySerializedRef(name, subob, 0, keychain)
@@ -49,8 +52,8 @@
def deserialize(self, object, event, state):
assert state is None
data = {}
- for name, keychain in self.map.items():
- subob = event.dereference(name, keychain)
+ for name, (keychain, mapper_names) in self.map.items():
+ subob = event.dereference(name, keychain, mapper_names)
data[name] = subob
# The PersistentMapping doesn't have its data or _container
# attribute yet, and we don't know what its name should be
=== Products/AdaptableStorage/serial_std/public.py 1.3 => 1.4 ===
--- Products/AdaptableStorage/serial_std/public.py:1.3 Thu Dec 5 12:38:47 2002
+++ Products/AdaptableStorage/serial_std/public.py Sat Dec 7 00:59:14 2002
@@ -16,6 +16,7 @@
$Id$
"""
+from FixedClassifier import FixedClassifier
from FixedPersistentMapping import FixedPersistentMapping
from FullState import FullState
from IgnoredAttribute import IgnoredAttribute