[Zope-CVS] CVS: Products/AdaptableStorage - Zope2FS.py:1.11

Shane Hathaway shane@zope.com
Wed, 11 Dec 2002 18:07:24 -0500


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

Modified Files:
	Zope2FS.py 
Log Message:
Added mappers for page templates, images, and files, making the claim of
custom formats more believable.


=== Products/AdaptableStorage/Zope2FS.py 1.10 => 1.11 ===
--- Products/AdaptableStorage/Zope2FS.py:1.10	Mon Dec  9 17:11:07 2002
+++ Products/AdaptableStorage/Zope2FS.py	Wed Dec 11 18:07:23 2002
@@ -21,8 +21,10 @@
      import ObjectSerializer, ObjectGateway, ObjectMapper
 from serial_std.public \
      import RollCall, FixedPersistentMapping, IgnoredAttribute, \
-     RemainingState, PathKeychainGenerator, AnyObjectSerializer
-from serial_ofs.public import FolderItems, MetaTypeClassifier, IdAttribute
+     RemainingState, PathKeychainGenerator, AnyObjectSerializer, \
+     StringDataAttribute
+from serial_ofs.public import FolderItems, MetaTypeClassifier, IdAttribute, \
+     FilePData
 from gateway_fs.public import FSConnection, FSDirectoryItems, FSAutoId, \
      FSSectionData, FSClassificationSection, FSFileData
 
@@ -42,6 +44,28 @@
     s.addAspect('remainder', RemainingState())
     object_serializers['OFS.Folder.Folder'] = s
 
+    # page template serializer
+    s = ObjectSerializer('Products.PageTemplates.ZopePageTemplate',
+                         'ZopePageTemplate')
+    s.addAspect('text', StringDataAttribute('_text'))
+    s.addAspect('id', IdAttribute())
+    s.addAspect('remainder', RemainingState())
+    object_serializers['ZopePageTemplate'] = s  # abbreviated. :-)
+
+    # file serializer
+    s = ObjectSerializer('OFS.Image', 'File')
+    s.addAspect('id', IdAttribute())
+    s.addAspect('data', FilePData())
+    s.addAspect('remainder', RemainingState())
+    object_serializers['OFS.Image.File'] = s
+
+    # image serializer
+    s = ObjectSerializer('OFS.Image', 'Image')
+    s.addAspect('id', IdAttribute())
+    s.addAspect('data', FilePData())
+    s.addAspect('remainder', RemainingState())
+    object_serializers['OFS.Image.Image'] = s
+
     # anyfolder serializer
     s = AnyObjectSerializer()
     s.addAspect('items', FolderItems())
@@ -78,6 +102,23 @@
     g.addGateway('remainder', FSSectionData(fs_conn, 'remainder'))
     object_gateways['OFS.Folder.Folder'] = g
 
+    # page template gateway
+    g = ObjectGateway()
+    g.addGateway('text', FSFileData(fs_conn))
+    g.addGateway('id', FSAutoId())
+    g.addGateway('remainder', FSSectionData(fs_conn, 'remainder'))
+    object_gateways['ZopePageTemplate'] = g
+
+    # file gateway
+    g = ObjectGateway()
+    g.addGateway('data', FSFileData(fs_conn))
+    g.addGateway('id', FSAutoId())
+    g.addGateway('remainder', FSSectionData(fs_conn, 'remainder'))
+    object_gateways['OFS.Image.File'] = g
+
+    # image gateway is identical
+    object_gateways['OFS.Image.Image'] = g
+
     # anyfolder object gateway
     g = ObjectGateway()
     g.addGateway('items', FSDirectoryItems(fs_conn))
@@ -111,10 +152,17 @@
     # Put everything together
     classifier = MetaTypeClassifier(FSClassificationSection(fs_conn))
     classifier.registerDefaultLoader('Folder', 'OFS.Folder.Folder', 1)
+    classifier.registerDefaultLoader('File', 'OFS.Image.File', 0)
     classifier.registerDefaultStorage('(folderish object)', 'anyfolder', 1)
     classifier.registerDefaultStorage('(fileish object)', 'anyfile', 0)
     classifier.registerKey('Application', 'OFS.Application.Application', '/')
     classifier.register('CMF Skins Tool', 'anyfile')  # XXX workaround
+
+    classifier.register('Page Template', 'ZopePageTemplate', (
+        '.pt', '.zpt', '.html'))
+    classifier.register('Image', 'OFS.Image.Image', (
+        '.gif', '.jpg', '.jpeg', '.png'))
+
     keychain_gen = PathKeychainGenerator()
     rm = ObjectMapper(
         None, root_serializer, root_gateway, classifier, keychain_gen)