[Zope-CVS] CVS: Products/AdaptableStorage - Zope2FS.py:1.1 __init__.py:1.4

Shane Hathaway shane@zope.com
Wed, 27 Nov 2002 13:37:36 -0500


Update of /cvs-repository/Products/AdaptableStorage
In directory cvs.zope.org:/tmp/cvs-serv12157

Added Files:
	Zope2FS.py __init__.py 
Log Message:
Moved the latest AdaptableStorage work out of the private repository.
It took a long time, but I moved it as soon as all the unit tests
passed and I felt that all the interface names and conventions were
good enough.

Documentation is still minimal, but now I think the system is finally
straight enough in my head to write down. :-) If you want a sneak
peek, the interfaces have some docstrings, if you're looking for a
"tree" view, while the OpenOffice diagram presents something of a
"forest" view.

Also note that I'm trying a new coding convention.  The "public"
module in each package defines exactly which objects should be
exported from the package.  This solves a few problems with imports
such as doubling of names and shadowing of modules.  Overall, the
"public" module makes it easier to tell which classes are supposed to
be used by other packages, and makes it easier for other packages to
use the public classes.  See what you think.



=== Added File Products/AdaptableStorage/Zope2FS.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.
#
##############################################################################
"""A basic mapping from Zope 2 objects to the filesystem.

$Id: Zope2FS.py,v 1.1 2002/11/27 18:37:05 shane Exp $
"""


from serial.public \
     import ObjectSerializer, ObjectGateway, ObjectMapper, DomainMapper
from serial_std.public \
     import RollCall, FixedPersistentMapping, IgnoredAttribute
from serial_ofs.public import FolderItems, MetaTypeClassifier, IdAttribute
from gateway_fs.public import FSConnection, FSDirectoryItems, FSAutoId



def createDomainMapper(basepath, volatile=1):
    fs_conn = FSConnection(basepath)

    object_serializers = {}
    object_gateways = {}

    # SERIALIZERS

    # folder serializer
    class_info = (('OFS.Folder', 'Folder'), None)
    s = ObjectSerializer(class_info)
    s.addAspect('items', FolderItems())
    s.addAspect('id', IdAttribute())
    s.addAspect('roll_call', RollCall())
    object_serializers['OFS/Folder'] = s

    # application serializer
    class_info = (('OFS.Application', 'Application'), None)
    s = ObjectSerializer(class_info)
    s.addAspect('items', FolderItems())
    s.addAspect('roll_call', RollCall())
    object_serializers['OFS/Application'] = s

    # root serializer
    class_info = (('Persistence', 'PersistentMapping'), None)
    s = ObjectSerializer(class_info)
    aspect = FixedPersistentMapping({'Application': ('OFS/Application', '')})
    s.addAspect('items', aspect)
    s.addAspect('roll_call', RollCall())
    object_serializers['root'] = s

    # GATEWAYS

    # folder gateway
    g = ObjectGateway()
    g.addGateway('items', FSDirectoryItems(fs_conn))
    g.addGateway('id', FSAutoId())
    object_gateways['OFS/Folder'] = g

    # application gateway
    g = ObjectGateway()
    g.addGateway('items', FSDirectoryItems(fs_conn))
    object_gateways['OFS/Application'] = g

    # root gateway (no storage)
    g = ObjectGateway()
    object_gateways['root'] = g

    # Sanity check
    s_keys = object_serializers.keys()
    s_keys.sort()
    g_keys = object_gateways.keys()
    g_keys.sort()
    assert s_keys == g_keys

    # Put everything together
    classifier = MetaTypeClassifier()
    classifier.registerNodeTypeDefault('Folder', 'OFS/Folder', 1)
    dm = DomainMapper(classifier)
    for name in s_keys:
        mapper = ObjectMapper(object_serializers[name],
                              object_gateways[name],
                              dm, volatile)
        dm.addMapper(name, mapper)

    return dm



=== Products/AdaptableStorage/__init__.py 1.3 => 1.4 ===
--- /dev/null	Wed Nov 27 13:37:36 2002
+++ Products/AdaptableStorage/__init__.py	Wed Nov 27 13:37:05 2002
@@ -0,0 +1,21 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""AdaptableStorage.
+
+Pattern names derived from:
+
+http://www.martinfowler.com/isa/OR-mapping.html
+
+$Id$
+"""