[Zope-CVS] CVS: Products/AdaptableStorage - Zope2FS.py:1.5
Shane Hathaway
shane@zope.com
Fri, 6 Dec 2002 17:07:20 -0500
Update of /cvs-repository/Products/AdaptableStorage
In directory cvs.zope.org:/tmp/cvs-serv8198
Modified Files:
Zope2FS.py
Log Message:
Experiment: removed mapper_name from OIDs, with the intent of allowing
loading and storage by different mappers depending on what the classifier
specifies. Not yet complete. Involved changes to virtually every module. :-)
I may decide to revert this. The shane-before-mapper-name-removal tag
was added just before this checkin.
=== Products/AdaptableStorage/Zope2FS.py 1.4 => 1.5 ===
--- Products/AdaptableStorage/Zope2FS.py:1.4 Thu Dec 5 12:38:46 2002
+++ Products/AdaptableStorage/Zope2FS.py Fri Dec 6 17:06:49 2002
@@ -18,7 +18,7 @@
from serial.public \
- import ObjectSerializer, ObjectGateway, ObjectMapper, DomainMapper
+ import ObjectSerializer, ObjectGateway, ObjectMapper
from serial_std.public \
import RollCall, FixedPersistentMapping, IgnoredAttribute, \
RemainingState
@@ -27,7 +27,7 @@
FSSectionData, FSClassificationSection
-def createDomainMapper(basepath, volatile=1):
+def createMapper(basepath, volatile=1):
fs_conn = FSConnection(basepath)
object_serializers = {}
@@ -36,33 +36,29 @@
# SERIALIZERS
# folder serializer
- class_info = (('OFS.Folder', 'Folder'), None)
- s = ObjectSerializer(class_info)
+ s = ObjectSerializer('OFS.Folder', 'Folder')
s.addAspect('items', FolderItems())
s.addAspect('id', IdAttribute())
s.addAspect('remainder', RemainingState())
object_serializers['OFS/Folder'] = s
# application serializer
- class_info = (('OFS.Application', 'Application'), None)
- s = ObjectSerializer(class_info)
+ s = ObjectSerializer('OFS.Application', 'Application')
s.addAspect('items', FolderItems())
s.addAspect('remainder', RemainingState())
object_serializers['OFS/Application'] = s
# root serializer
- class_info = (('Persistence', 'PersistentMapping'), None)
- s = ObjectSerializer(class_info)
- aspect = FixedPersistentMapping({'Application': ('OFS/Application', '')})
+ s = ObjectSerializer('Persistence', 'PersistentMapping')
+ aspect = FixedPersistentMapping({'Application': ('/',)})
s.addAspect('items', aspect)
s.addAspect('roll_call', RollCall())
- object_serializers['root'] = s
+ root_serializer = s
# GATEWAYS
# folder gateway
g = ObjectGateway()
- g.addGateway('classification', FSClassificationSection(fs_conn))
g.addGateway('items', FSDirectoryItems(fs_conn))
g.addGateway('id', FSAutoId())
g.addGateway('remainder', FSSectionData(fs_conn, 'remainder'))
@@ -76,7 +72,7 @@
# root gateway (no storage)
g = ObjectGateway()
- object_gateways['root'] = g
+ root_gateway = g
# Sanity check
s_keys = object_serializers.keys()
@@ -86,16 +82,16 @@
assert s_keys == g_keys
# Put everything together
- classifier = MetaTypeClassifier()
- classifier.registerNodeTypeDefault('Folder', 'OFS/Folder', 1)
- dm = DomainMapper(classifier)
+ classifier = MetaTypeClassifier(FSClassificationSection(fs_conn))
+ classifier.registerDefaultLoader('Folder', 'OFS/Folder', 1)
+ classifier.registerKey('Application', 'OFS/Application', '/')
+ rm = ObjectMapper(None, root_serializer, root_gateway, classifier)
for name in s_keys:
- mapper = ObjectMapper(object_serializers[name],
- object_gateways[name],
- dm, volatile)
- dm.addMapper(name, mapper)
+ mapper = ObjectMapper(rm, object_serializers[name],
+ object_gateways[name], volatile=volatile)
+ rm.addSubMapper(name, mapper)
- return dm, fs_conn
+ return rm, fs_conn
# For use in dbtab.conf:
@@ -106,7 +102,7 @@
class FSStorage (ASStorage):
def __init__(self, basepath, volatile=0, **kw):
- dm, fs_conn = createDomainMapper(basepath, int(volatile))
+ dm, fs_conn = createMapper(basepath, int(volatile))
res = StaticResource(dm)
ASStorage.__init__(self, res, [fs_conn], **kw)