[Zope-Checkins] CVS: Products/AdaptableStorage/serial_ofs - UserFolderSerializer.py:1.1 public.py:1.5
Shane Hathaway
shane@zope.com
Mon, 6 Jan 2003 18:18:24 -0500
Update of /cvs-repository/Products/AdaptableStorage/serial_ofs
In directory cvs.zope.org:/tmp/cvs-serv1755/serial_ofs
Modified Files:
public.py
Added Files:
UserFolderSerializer.py
Log Message:
- Added a user folder mapper for the filesystem. SQL version coming
soon. (SQL tests fail at the moment.)
- Added unwriteData() to FSConnection. I may remove it later, since it turned
out I didn't need it.
- Made configuration errors easier to read.
- Added null implementations of certain interfaces.
- Added a default for FixedClassifier.
=== Added File Products/AdaptableStorage/serial_ofs/UserFolderSerializer.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 a user folder.
This version lets the application keep a list of all users in RAM.
$Id: UserFolderSerializer.py,v 1.1 2003/01/06 23:17:51 shane Exp $
"""
from AccessControl.User import User, UserFolder
from Persistence import PersistentMapping
from mapper_public import IAspectSerializer, RowSequenceSchema
class UserFolderSerializer:
__implements__ = IAspectSerializer
schema = RowSequenceSchema()
schema.addField('id', 'string', 1)
schema.addField('password', 'string')
schema.addField('roles', 'string:list')
schema.addField('domains', 'string:list')
def getSchema(self):
return self.schema
def canSerialize(self, object):
return isinstance(object, UserFolder)
def serialize(self, object, event):
assert isinstance(object, UserFolder), repr(object)
state = []
event.ignoreAttribute('data')
for id, user in object.data.items():
assert isinstance(user, User), repr(user)
state.append((id, user.__,
tuple(user.roles), tuple(user.domains)))
event.notifySerialized(id, user, 0)
event.addUnmanagedPersistentObjects(object.data.values())
return state
def deserialize(self, object, event, state):
assert isinstance(object, UserFolder)
object.data = PersistentMapping()
for id, password, roles, domains in state:
user = User(id, password, roles, domains)
object.data[id] = user
event.notifyDeserialized(id, user)
event.addUnmanagedPersistentObjects(object.data.values())
=== Products/AdaptableStorage/serial_ofs/public.py 1.4 => 1.5 ===
--- Products/AdaptableStorage/serial_ofs/public.py:1.4 Fri Jan 3 17:04:22 2003
+++ Products/AdaptableStorage/serial_ofs/public.py Mon Jan 6 18:17:51 2003
@@ -22,3 +22,5 @@
from IdAttribute import IdAttribute
from MetaTypeClassifier import MetaTypeClassifier
from OFSProperties import OFSProperties
+from UserFolderSerializer import UserFolderSerializer
+