[Zope-CVS] CVS: Products/AdaptableStorage - Zope2FS.py:1.20 Zope2Mapper.py:1.11 Zope2SQL.py:1.13
Shane Hathaway
shane@zope.com
Fri, 21 Feb 2003 11:08:39 -0500
Update of /cvs-repository/Products/AdaptableStorage
In directory cvs.zope.org:/tmp/cvs-serv5192
Modified Files:
Zope2FS.py Zope2Mapper.py Zope2SQL.py
Log Message:
- Fixed storage and loading of ZClass instances.
IObjectSerializer.createEmptyInstance() now accepts an optional
class_loader. ASConnection provides a class loader that can load
ZClasses.
- Simplified configuration of mappers using "base" mappers. Derived
mappers and gateways start with the configuration of the base mapper.
- Enhanced the configurability of ObjectGateways and
ObjectSerializers: there are now removeGateway() and removeAspect()
methods.
=== Products/AdaptableStorage/Zope2FS.py 1.19 => 1.20 ===
--- Products/AdaptableStorage/Zope2FS.py:1.19 Thu Feb 6 14:08:50 2003
+++ Products/AdaptableStorage/Zope2FS.py Fri Feb 21 11:08:08 2003
@@ -37,94 +37,77 @@
root_mapper = createZope2Mapper('/', 0)
root_mapper.getClassifier().setGateway(FSClassificationSection(conn))
root_mapper.setKeychainGenerator(PathKeychainGenerator())
+ file_data = FSFileData(conn)
- item_id_gw = FSAutoId()
- properties_gw = FSProperties(conn)
- remainder_gw = FSSectionData(conn, 'remainder')
+ # abstract base gateway
+ g = ObjectGateway()
+ g.addGateway('id', FSAutoId())
+ g.addGateway('properties', FSProperties(conn))
+ g.addGateway('remainder', FSSectionData(conn, 'remainder'))
+ root_mapper.getSubMapper('base').setGateway(g)
+ base = g
# folder gateway
- g = ObjectGateway()
+ g = ObjectGateway(base)
g.addGateway('items', FSDirectoryItems(conn))
- g.addGateway('properties', properties_gw)
- g.addGateway('id', item_id_gw)
- g.addGateway('remainder', remainder_gw)
root_mapper.getSubMapper('OFS.Folder.Folder').setGateway(g)
# page template gateway
- g = ObjectGateway()
- g.addGateway('text', FSFileData(conn))
- g.addGateway('properties', properties_gw)
- g.addGateway('id', item_id_gw)
- g.addGateway('remainder', remainder_gw)
+ g = ObjectGateway(base)
+ g.addGateway('text', file_data)
root_mapper.getSubMapper('ZopePageTemplate').setGateway(g)
# dtml method gateway
- g = ObjectGateway()
- g.addGateway('text', FSFileData(conn))
- g.addGateway('id', item_id_gw)
- g.addGateway('remainder', remainder_gw)
+ g = ObjectGateway(base)
+ g.addGateway('text', file_data)
+ g.removeGateway('properties')
root_mapper.getSubMapper('OFS.DTMLMethod.DTMLMethod').setGateway(g)
# dtml document gateway
- g = ObjectGateway()
- g.addGateway('text', FSFileData(conn))
- g.addGateway('properties', properties_gw)
- g.addGateway('id', item_id_gw)
- g.addGateway('remainder', remainder_gw)
+ g = ObjectGateway(base)
+ g.addGateway('text', file_data)
root_mapper.getSubMapper('OFS.DTMLDocument.DTMLDocument').setGateway(g)
# zsqlmethod mapper
- g = ObjectGateway()
- g.addGateway('text', FSFileData(conn))
- g.addGateway('properties', FSProperties(conn, 'ZSQL Properties'))
- g.addGateway('id', item_id_gw)
- g.addGateway('remainder', remainder_gw)
+ g = ObjectGateway(base)
+ g.addGateway('text', file_data)
+ g.addGateway('properties', FSProperties(conn, 'ZSQL Properties'), 1)
root_mapper.getSubMapper('Products.ZSQLMethods.SQL.SQL').setGateway(g)
# python script mapper
- g = ObjectGateway()
- g.addGateway('body', FSFileData(conn))
- g.addGateway('id', item_id_gw)
- g.addGateway('remainder', remainder_gw)
+ g = ObjectGateway(base)
+ g.removeGateway('properties')
+ g.addGateway('body', file_data)
root_mapper.getSubMapper('PythonScript').setGateway(g)
# file gateway
- g = ObjectGateway()
- g.addGateway('data', FSFileData(conn))
- g.addGateway('properties', properties_gw)
- g.addGateway('id', item_id_gw)
- g.addGateway('remainder', remainder_gw)
+ g = ObjectGateway(base)
+ g.addGateway('data', file_data)
root_mapper.getSubMapper('OFS.Image.File').setGateway(g)
# image gateway is identical
root_mapper.getSubMapper('OFS.Image.Image').setGateway(g)
# user folder gateway
- g = ObjectGateway()
+ g = ObjectGateway(base)
+ g.removeGateway('properties')
g.addGateway('data', FSUserList(conn))
- g.addGateway('id', item_id_gw)
- g.addGateway('remainder', remainder_gw)
root_mapper.getSubMapper('AccessControl.User.UserFolder').setGateway(g)
# anyfolder object gateway
- g = ObjectGateway()
+ g = ObjectGateway(base)
g.addGateway('items', FSDirectoryItems(conn))
- g.addGateway('properties', properties_gw)
- g.addGateway('id', item_id_gw)
- g.addGateway('remainder', remainder_gw)
root_mapper.getSubMapper('anyfolder').setGateway(g)
# anyfile object gateway
- g = ObjectGateway()
- g.addGateway('id', item_id_gw)
- g.addGateway('remainder', FSFileData(conn))
+ g = ObjectGateway(base)
+ g.addGateway('remainder', file_data, 1)
root_mapper.getSubMapper('anyfile').setGateway(g)
# application gateway
- g = ObjectGateway()
- g.addGateway('properties', properties_gw)
+ g = ObjectGateway(base)
+ g.removeGateway('id')
g.addGateway('items', FSDirectoryItems(conn))
- g.addGateway('remainder', remainder_gw)
root_mapper.getSubMapper('OFS.Application.Application').setGateway(g)
root_mapper.checkConfiguration()
=== Products/AdaptableStorage/Zope2Mapper.py 1.10 => 1.11 ===
--- Products/AdaptableStorage/Zope2Mapper.py:1.10 Mon Feb 10 22:46:00 2003
+++ Products/AdaptableStorage/Zope2Mapper.py Fri Feb 21 11:08:08 2003
@@ -50,39 +50,36 @@
folder_items_aspect = FolderItemsByKeychain()
else:
folder_items_aspect = FolderItems()
- properties_aspect = OFSProperties()
- id_aspect = IdAttribute()
- remainder_aspect = RemainingState()
+
+ # abstract base mapper
+ m = root_mapper.addSubMapper('base')
+ s = ObjectSerializer(None, None)
+ m.setSerializer(s)
+ s.addAspect('id', IdAttribute())
+ s.addAspect('properties', OFSProperties())
+ s.addAspect('remainder', RemainingState(), final=1)
+ base = s
# folder mapper
m = root_mapper.addSubMapper('OFS.Folder.Folder')
- s = ObjectSerializer('OFS.Folder', 'Folder')
+ s = ObjectSerializer('OFS.Folder', 'Folder', base)
m.setSerializer(s)
- s.addAspect('id', id_aspect)
- s.addAspect('properties', properties_aspect)
s.addAspect('items', folder_items_aspect)
- s.addAspect('remainder', remainder_aspect)
classifier.registerDefaultLoader('Folder', 'OFS.Folder.Folder', 1)
# file mapper
m = root_mapper.addSubMapper('OFS.Image.File')
- s = ObjectSerializer('OFS.Image', 'File')
+ s = ObjectSerializer('OFS.Image', 'File', base)
m.setSerializer(s)
- s.addAspect('id', id_aspect)
- s.addAspect('properties', properties_aspect)
s.addAspect('data', FilePData())
- s.addAspect('remainder', remainder_aspect)
classifier.registerDefaultLoader('File', 'OFS.Image.File', 0)
classifier.setFlags('OFS.Image.File', classifier.CONTENT_TYPE_ATTR)
# image mapper
m = root_mapper.addSubMapper('OFS.Image.Image')
- s = ObjectSerializer('OFS.Image', 'Image')
+ s = ObjectSerializer('OFS.Image', 'Image', base)
m.setSerializer(s)
- s.addAspect('id', id_aspect)
- s.addAspect('properties', properties_aspect)
s.addAspect('data', FilePData())
- s.addAspect('remainder', remainder_aspect)
classifier.register('Image', 'OFS.Image.Image', (
'.gif', '.jpg', '.jpeg', '.png'))
classifier.setFlags('OFS.Image.Image', classifier.CONTENT_TYPE_ATTR)
@@ -90,89 +87,74 @@
# page template mapper
m = root_mapper.addSubMapper('ZopePageTemplate') # abbreviated name
s = ObjectSerializer('Products.PageTemplates.ZopePageTemplate',
- 'ZopePageTemplate')
+ 'ZopePageTemplate', base)
m.setSerializer(s)
- s.addAspect('id', id_aspect)
- s.addAspect('properties', properties_aspect)
s.addAspect('text', StringDataAttribute('_text'))
- s.addAspect('remainder', remainder_aspect)
classifier.register('Page Template', 'ZopePageTemplate', (
'.html', '.htm', '.zpt', '.pt'))
# dtml method mapper
m = root_mapper.addSubMapper('OFS.DTMLMethod.DTMLMethod')
- s = ObjectSerializer('OFS.DTMLMethod', 'DTMLMethod')
+ s = ObjectSerializer('OFS.DTMLMethod', 'DTMLMethod', base)
m.setSerializer(s)
- s.addAspect('id', id_aspect)
s.addAspect('text', StringDataAttribute('raw'))
- s.addAspect('remainder', remainder_aspect)
+ s.removeAspect('properties')
classifier.register('DTML Method', 'OFS.DTMLMethod.DTMLMethod', ('.dtml',))
# dtml document mapper
m = root_mapper.addSubMapper('OFS.DTMLDocument.DTMLDocument')
- s = ObjectSerializer('OFS.DTMLDocument', 'DTMLDocument')
+ s = ObjectSerializer('OFS.DTMLDocument', 'DTMLDocument', base)
m.setSerializer(s)
- s.addAspect('id', id_aspect)
- s.addAspect('properties', properties_aspect)
s.addAspect('text', StringDataAttribute('raw'))
- s.addAspect('remainder', remainder_aspect)
classifier.register('DTML Document', 'OFS.DTMLDocument.DTMLDocument')
# zsql mapper
m = root_mapper.addSubMapper('Products.ZSQLMethods.SQL.SQL')
- s = ObjectSerializer('Products.ZSQLMethods.SQL', 'SQL')
+ s = ObjectSerializer('Products.ZSQLMethods.SQL', 'SQL', base)
m.setSerializer(s)
- s.addAspect('id', id_aspect)
- s.addAspect('properties', ZSQLMethodPropertiesSerializer())
+ s.addAspect('properties', ZSQLMethodPropertiesSerializer(), 1)
s.addAspect('text', ZSQLMethodSerializer())
- s.addAspect('remainder', remainder_aspect)
classifier.register('Z SQL Method', 'Products.ZSQLMethods.SQL.SQL', (
'.sql', ))
# python script mapper
m = root_mapper.addSubMapper('PythonScript') # abbreviated name
s = ObjectSerializer('Products.PythonScripts.PythonScript',
- 'PythonScript')
+ 'PythonScript', base)
m.setSerializer(s)
- s.addAspect('id', id_aspect)
s.addAspect('body', PythonScriptSerializer())
- s.addAspect('remainder', remainder_aspect)
+ s.removeAspect('properties')
classifier.register('Script (Python)', 'PythonScript', ('.py', ))
# user folder mapper
m = root_mapper.addSubMapper('AccessControl.User.UserFolder')
- s = ObjectSerializer('AccessControl.User', 'UserFolder')
+ s = ObjectSerializer('AccessControl.User', 'UserFolder', base)
m.setSerializer(s)
- s.addAspect('id', id_aspect)
s.addAspect('data', UserFolderSerializer())
- s.addAspect('remainder', remainder_aspect)
+ s.removeAspect('properties')
classifier.register('User Folder', 'AccessControl.User.UserFolder')
# anyfolder mapper
m = root_mapper.addSubMapper('anyfolder')
- s = AnyObjectSerializer()
+ s = AnyObjectSerializer(base)
m.setSerializer(s)
- s.addAspect('id', id_aspect)
- s.addAspect('properties', OptionalAspect(properties_aspect, []))
+ s.addAspect('properties', OptionalAspect(OFSProperties(), []), 1)
s.addAspect('items', folder_items_aspect)
- s.addAspect('remainder', remainder_aspect)
classifier.registerDefaultStorage('(folderish object)', 'anyfolder', 1)
# anyfile mapper
m = root_mapper.addSubMapper('anyfile')
- s = AnyObjectSerializer()
+ s = AnyObjectSerializer(base)
m.setSerializer(s)
- s.addAspect('id', id_aspect)
- s.addAspect('remainder', remainder_aspect)
+ s.addAspect('properties', OptionalAspect(OFSProperties(), []), 1)
classifier.registerDefaultStorage('(fileish object)', 'anyfile', 0)
# application mapper
m = root_mapper.addSubMapper('OFS.Application.Application')
- s = ObjectSerializer('OFS.Application', 'Application')
+ s = ObjectSerializer('OFS.Application', 'Application', base)
m.setSerializer(s)
- s.addAspect('properties', properties_aspect)
+ s.removeAspect('id')
s.addAspect('items', folder_items_aspect)
- s.addAspect('remainder', remainder_aspect)
classifier.registerKey(
'Application', 'OFS.Application.Application', app_key)
=== Products/AdaptableStorage/Zope2SQL.py 1.12 => 1.13 ===
--- Products/AdaptableStorage/Zope2SQL.py:1.12 Thu Feb 6 14:08:50 2003
+++ Products/AdaptableStorage/Zope2SQL.py Fri Feb 21 11:08:08 2003
@@ -49,89 +49,73 @@
keychain_gen,
)
- # folder gateway
+ # abstract base gateway
g = ObjectGateway()
- g.addGateway('items', folder_items_gw)
- g.addGateway('properties', properties_gw)
g.addGateway('id', item_id_gw)
+ g.addGateway('properties', properties_gw)
g.addGateway('remainder', remainder_gw)
+ root_mapper.getSubMapper('base').setGateway(g)
+ base = g
+
+ # folder gateway
+ g = ObjectGateway(base)
+ g.addGateway('items', folder_items_gw)
root_mapper.getSubMapper('OFS.Folder.Folder').setGateway(g)
# page template gateway
- g = ObjectGateway()
+ g = ObjectGateway(base)
g.addGateway('text', file_data_gw)
- g.addGateway('properties', properties_gw)
- g.addGateway('id', item_id_gw)
- g.addGateway('remainder', remainder_gw)
root_mapper.getSubMapper('ZopePageTemplate').setGateway(g)
# dtml method gateway
- g = ObjectGateway()
+ g = ObjectGateway(base)
g.addGateway('text', file_data_gw)
- g.addGateway('id', item_id_gw)
- g.addGateway('remainder', remainder_gw)
+ g.removeGateway('properties')
root_mapper.getSubMapper('OFS.DTMLMethod.DTMLMethod').setGateway(g)
# dtml document gateway
- g = ObjectGateway()
+ g = ObjectGateway(base)
g.addGateway('text', file_data_gw)
- g.addGateway('properties', properties_gw)
- g.addGateway('id', item_id_gw)
- g.addGateway('remainder', remainder_gw)
root_mapper.getSubMapper('OFS.DTMLDocument.DTMLDocument').setGateway(g)
# zsqlmethod mapper
- g = ObjectGateway()
+ g = ObjectGateway(base)
g.addGateway('text', file_data_gw)
- g.addGateway('properties', properties_gw)
- g.addGateway('id', item_id_gw)
- g.addGateway('remainder', remainder_gw)
root_mapper.getSubMapper('Products.ZSQLMethods.SQL.SQL').setGateway(g)
# python script mapper
- g = ObjectGateway()
+ g = ObjectGateway(base)
g.addGateway('body', file_data_gw)
- g.addGateway('id', item_id_gw)
- g.addGateway('remainder', remainder_gw)
+ g.removeGateway('properties')
root_mapper.getSubMapper('PythonScript').setGateway(g)
# file gateway
- g = ObjectGateway()
+ g = ObjectGateway(base)
g.addGateway('data', file_data_gw)
- g.addGateway('properties', properties_gw)
- g.addGateway('id', item_id_gw)
- g.addGateway('remainder', remainder_gw)
root_mapper.getSubMapper('OFS.Image.File').setGateway(g)
# image gateway is identical
root_mapper.getSubMapper('OFS.Image.Image').setGateway(g)
# user folder gateway
- g = ObjectGateway()
+ g = ObjectGateway(base)
g.addGateway('data', SQLUserList(conn))
- g.addGateway('id', item_id_gw)
- g.addGateway('remainder', remainder_gw)
+ g.removeGateway('properties')
root_mapper.getSubMapper('AccessControl.User.UserFolder').setGateway(g)
# anyfolder object gateway
- g = ObjectGateway()
+ g = ObjectGateway(base)
g.addGateway('items', folder_items_gw)
- g.addGateway('properties', properties_gw)
- g.addGateway('id', item_id_gw)
- g.addGateway('remainder', remainder_gw)
root_mapper.getSubMapper('anyfolder').setGateway(g)
# anyfile object gateway
- g = ObjectGateway()
- g.addGateway('id', item_id_gw)
- g.addGateway('remainder', remainder_gw)
+ g = ObjectGateway(base)
root_mapper.getSubMapper('anyfile').setGateway(g)
# application gateway
- g = ObjectGateway()
+ g = ObjectGateway(base)
+ g.removeGateway('id')
g.addGateway('items', folder_items_gw)
- g.addGateway('properties', properties_gw)
- g.addGateway('remainder', remainder_gw)
root_mapper.getSubMapper('OFS.Application.Application').setGateway(g)
root_mapper.checkConfiguration()