[Zope-CVS] CVS: Products/Ape/lib/apelib/zope2 - baseconf.py:1.1.2.1

Shane Hathaway shane@zope.com
Thu, 19 Jun 2003 23:24:02 -0400


Update of /cvs-repository/Products/Ape/lib/apelib/zope2
In directory cvs.zope.org:/tmp/cvs-serv1158

Added Files:
      Tag: ape-newconf-branch
	baseconf.py 
Log Message:
Skeleton for a new way to configure mappers

=== Added File Products/Ape/lib/apelib/zope2/baseconf.py ===


from apelib.core import gateways, mapper, serializers
from apelib.zodb3 import serializers as zodb3serializers
from apelib.zope2 import classifier, ofsserial, scripts, security


class AbstractConfiguration(mapper.MapperConfiguration):
    name = 'base'
    serializers = [
        ('id', ofsserial.IdAttribute()),
        ('modtime', zodb3serializers.ModTimeAttribute()),
        ('security', security.SecurityAttributes()),
        ]
    final_serializers = [
        ('remainder', zodb3serializers.RemainingState()),
        ]


class AbstractPropertyConfiguration(mapper.MapperConfiguration):
    base = 'base'
    name = 'base_p'
    serializers = [
        ('properties', ofsserial.OFSProperties()),
        ]


def getFolderItemsSerializer(stored_keychains):
    if stored_keychains:
        return ofsserial.FolderItemsByKeychain()
    else:
        return ofsserial.FolderItems()


class FolderConfiguration(mapper.MapperConfiguration):
    base = 'base_p'
    name = class_name = 'OFS.Folder.Folder'
    def __init__(self, stored_keychains):
        self.serializers = [
            ('items', getFolderItemsSerializer(stored_keychains)),
            ]


class FileConfiguration(mapper.MapperConfiguration):
    base = 'base_p'
    name = class_name = 'OFS.Image.File'
    serializers = [
        ('data', ofsserial.FilePData()),
        ]
    classifier_flags = ('content_type_attr',)