[Zope-CVS] CVS: Products/Ape/apelib/zope2 - basemapper.py:1.3 fsmapper.py:1.2 sqlmapper.py:1.2

Shane Hathaway shane@zope.com
Sat, 29 Mar 2003 17:27:51 -0500


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

Modified Files:
	basemapper.py fsmapper.py sqlmapper.py 
Log Message:
Made _p_mtime work.  The modification time comes through a gateway and
gets installed by a serializer.

Note that the strategy we're using for SQL is starting to become
burdensome.  There is a lot of information we could collect with a
single query rather than several (currently a minimum of four queries
per object).  CompositeGateway is perhaps too simple.

Also updated the style of imports in sqlmapper and fsmapper.  By
importing modules rather than classes, the import statements are
simpler.  I think this is nice but not applicable everywhere.


=== Products/Ape/apelib/zope2/basemapper.py 1.2 => 1.3 ===
--- Products/Ape/apelib/zope2/basemapper.py:1.2	Wed Mar 19 16:38:50 2003
+++ Products/Ape/apelib/zope2/basemapper.py	Sat Mar 29 17:27:51 2003
@@ -47,6 +47,7 @@
     cs = serializers.CompositeSerializer(None, None)
     m.setSerializer(cs)
     cs.addSerializer('id', ofsserial.IdAttribute())
+    cs.addSerializer('modtime', zodb3serializers.ModTimeAttribute())
     cs.addSerializer('security', security.SecurityAttributes())
     cs.addSerializer('remainder', zodb3serializers.RemainingState(), final=1)
     base = cs


=== Products/Ape/apelib/zope2/fsmapper.py 1.1.1.1 => 1.2 ===
--- Products/Ape/apelib/zope2/fsmapper.py:1.1.1.1	Sat Mar 15 18:44:43 2003
+++ Products/Ape/apelib/zope2/fsmapper.py	Sat Mar 29 17:27:51 2003
@@ -16,14 +16,10 @@
 $Id$
 """
 
-from apelib.core.gateways import CompositeGateway
-from apelib.core.keygen import PathKeychainGenerator
-from apelib.fs.connection import FSConnection
-from apelib.fs.structure import FSAutoId, FSDirectoryItems, FSFileData
-from apelib.fs.classification import FSClassificationSection
-from apelib.fs.properties import FSProperties, FSSectionData
-from apelib.fs.security import FSSecurityAttributes, FSUserList
-from apelib.zope2.basemapper import createZope2Mapper
+from apelib.core import gateways, keygen
+from apelib.fs \
+     import classification, connection, properties, security, structure
+from apelib.zope2 import basemapper
 
 
 def createMapper(basepath, volatile=1, **kw):
@@ -33,59 +29,62 @@
     factory=apelib.zope2.fsmapper.createMapper
     """
     # The "volatile" argument is ignored.
-    conn = FSConnection(basepath, **kw)
-    root_mapper = createZope2Mapper('/', 0)
-    root_mapper.getClassifier().setGateway(FSClassificationSection(conn))
-    root_mapper.setKeychainGenerator(PathKeychainGenerator())
-    file_data = FSFileData(conn)
+    conn = connection.FSConnection(basepath, **kw)
+    root_mapper = basemapper.createZope2Mapper('/', 0)
+    root_mapper.getClassifier().setGateway(
+        classification.FSClassificationSection(conn))
+    root_mapper.setKeychainGenerator(keygen.PathKeychainGenerator())
+    file_data = structure.FSFileData(conn)
 
     # abstract base gateway
-    g = CompositeGateway()
-    g.addGateway('id', FSAutoId())
-    g.addGateway('remainder', FSSectionData(conn, 'remainder'))
-    g.addGateway('security', FSSecurityAttributes(conn))
+    g = gateways.CompositeGateway()
+    g.addGateway('id', structure.FSAutoId())
+    g.addGateway('modtime', structure.FSModTime(conn))
+    g.addGateway('remainder', properties.FSSectionData(conn, 'remainder'))
+    g.addGateway('security', security.FSSecurityAttributes(conn))
     root_mapper.getSubMapper('base').setGateway(g)
     base = g
 
     # abstract base gateway with properties
-    g = CompositeGateway(base)
-    g.addGateway('properties', FSProperties(conn))
+    g = gateways.CompositeGateway(base)
+    g.addGateway('properties', properties.FSProperties(conn))
     root_mapper.getSubMapper('base_p').setGateway(g)
     base_p = g
 
     # folder gateway
-    g = CompositeGateway(base_p)
-    g.addGateway('items', FSDirectoryItems(conn))
+    g = gateways.CompositeGateway(base_p)
+    g.addGateway('items', structure.FSDirectoryItems(conn))
     root_mapper.getSubMapper('OFS.Folder.Folder').setGateway(g)
 
     # page template gateway
-    g = CompositeGateway(base_p)
+    g = gateways.CompositeGateway(base_p)
     g.addGateway('text', file_data)
     root_mapper.getSubMapper('ZopePageTemplate').setGateway(g)
 
     # dtml method gateway
-    g = CompositeGateway(base)
+    g = gateways.CompositeGateway(base)
     g.addGateway('text', file_data)
     root_mapper.getSubMapper('OFS.DTMLMethod.DTMLMethod').setGateway(g)
     
     # dtml document gateway
-    g = CompositeGateway(base_p)
+    g = gateways.CompositeGateway(base_p)
     g.addGateway('text', file_data)
     root_mapper.getSubMapper('OFS.DTMLDocument.DTMLDocument').setGateway(g)
 
     # zsqlmethod mapper
-    g = CompositeGateway(base)
+    g = gateways.CompositeGateway(base)
     g.addGateway('text', file_data)
-    g.addGateway('properties', FSProperties(conn, 'ZSQL Properties'), 1)
+    g.addGateway('properties', properties.FSProperties(
+        conn, 'ZSQL Properties'), 1)
     root_mapper.getSubMapper('Products.ZSQLMethods.SQL.SQL').setGateway(g)
 
     # python script mapper
-    g = CompositeGateway(base)
+    g = gateways.CompositeGateway(base)
     g.addGateway('body', file_data)
     root_mapper.getSubMapper('PythonScript').setGateway(g)
 
     # file gateway
-    g = CompositeGateway(base_p)
+    g = gateways.CompositeGateway(base_p)
     g.addGateway('data', file_data)
     root_mapper.getSubMapper('OFS.Image.File').setGateway(g)
 
@@ -93,24 +92,24 @@
     root_mapper.getSubMapper('OFS.Image.Image').setGateway(g)
 
     # user folder gateway
-    g = CompositeGateway(base)
-    g.addGateway('data', FSUserList(conn))
+    g = gateways.CompositeGateway(base)
+    g.addGateway('data', security.FSUserList(conn))
     root_mapper.getSubMapper('AccessControl.User.UserFolder').setGateway(g)
 
     # anyfolder object gateway
-    g = CompositeGateway(base_p)
-    g.addGateway('items', FSDirectoryItems(conn))
+    g = gateways.CompositeGateway(base_p)
+    g.addGateway('items', structure.FSDirectoryItems(conn))
     root_mapper.getSubMapper('anyfolder').setGateway(g)
 
     # anyfile object gateway
-    g = CompositeGateway(base_p)
+    g = gateways.CompositeGateway(base_p)
     g.addGateway('remainder', file_data, 1)
     root_mapper.getSubMapper('anyfile').setGateway(g)
 
     # application gateway
-    g = CompositeGateway(base_p)
+    g = gateways.CompositeGateway(base_p)
     g.removeGateway('id')
-    g.addGateway('items', FSDirectoryItems(conn))
+    g.addGateway('items', structure.FSDirectoryItems(conn))
     root_mapper.getSubMapper('OFS.Application.Application').setGateway(g)
 
     root_mapper.checkConfiguration()


=== Products/Ape/apelib/zope2/sqlmapper.py 1.1.1.1 => 1.2 ===
--- Products/Ape/apelib/zope2/sqlmapper.py:1.1.1.1	Sat Mar 15 18:44:44 2003
+++ Products/Ape/apelib/zope2/sqlmapper.py	Sat Mar 29 17:27:51 2003
@@ -16,88 +16,89 @@
 $Id$
 """
 
-
-from apelib.core.gateways import CompositeGateway
-from apelib.sql.classification import SQLClassification
-from apelib.sql.structure \
-     import SQLFolderItems, SQLItemId, SQLObjectData, SQLRemainder
-from apelib.sql.keygen import SQLKeychainGenerator
-from apelib.sql.properties import SQLProperties
-from apelib.sql.security import SQLSecurityAttributes, SQLUserList
-from apelib.zope2.basemapper import createZope2Mapper
+from apelib.core import gateways
+from apelib.sql import classification, keygen, properties, security, structure
+from apelib.zope2 import basemapper
 
 
 def createSQLMapper(conn):
     """Object mapper factory, with extra return arg for testing purposes
     """
-    root_mapper = createZope2Mapper(0, 1)
-    root_mapper.getClassifier().setGateway(SQLClassification(conn))
-    root_mapper.setKeychainGenerator(SQLKeychainGenerator(conn))
-
-    folder_items_gw = SQLFolderItems(conn)
-    item_id_gw = SQLItemId(conn)
-    remainder_gw = SQLRemainder(conn)
-    file_data_gw = SQLObjectData(conn)
-    properties_gw = SQLProperties(conn)
-    security_gw = SQLSecurityAttributes(conn)
-    classification_gw = SQLClassification(conn)
-    keychain_gen = SQLKeychainGenerator(conn)
+    root_mapper = basemapper.createZope2Mapper(0, 1)
+    root_mapper.setKeychainGenerator(keygen.SQLKeychainGenerator(conn))
+
+    folder_items_gw = structure.SQLFolderItems(conn)
+    item_id_gw = structure.SQLItemId(conn)
+    remainder_gw = structure.SQLRemainder(conn)
+    file_data_gw = structure.SQLObjectData(conn)
+    modtime_gw = structure.SQLModTime(conn)
+    properties_gw = properties.SQLProperties(conn)
+    security_gw = security.SQLSecurityAttributes(conn)
+    userlist_gw = security.SQLUserList(conn)
+    classification_gw = classification.SQLClassification(conn)
+    keychain_gen = keygen.SQLKeychainGenerator(conn)
     gws = (
         folder_items_gw,
-        item_id_gw,
         remainder_gw,
+        item_id_gw,
         file_data_gw,
+        modtime_gw,
         properties_gw,
+        security_gw,
+        userlist_gw,
         classification_gw,
         keychain_gen,
         )
 
+    root_mapper.getClassifier().setGateway(classification_gw)
+
     # abstract base gateway
-    g = CompositeGateway()
+    g = gateways.CompositeGateway()
     g.addGateway('id', item_id_gw)
+    g.addGateway('modtime', modtime_gw)
     g.addGateway('remainder', remainder_gw)
     g.addGateway('security', security_gw)
     root_mapper.getSubMapper('base').setGateway(g)
     base = g
 
     # abstract base gateway with properties
-    g = CompositeGateway(base)
+    g = gateways.CompositeGateway(base)
     g.addGateway('properties', properties_gw)
     root_mapper.getSubMapper('base_p').setGateway(g)
     base_p = g
 
     # folder gateway
-    g = CompositeGateway(base_p)
+    g = gateways.CompositeGateway(base_p)
     g.addGateway('items', folder_items_gw)
     root_mapper.getSubMapper('OFS.Folder.Folder').setGateway(g)
 
     # page template gateway
-    g = CompositeGateway(base_p)
+    g = gateways.CompositeGateway(base_p)
     g.addGateway('text', file_data_gw)
     root_mapper.getSubMapper('ZopePageTemplate').setGateway(g)
 
     # dtml method gateway
-    g = CompositeGateway(base)
+    g = gateways.CompositeGateway(base)
     g.addGateway('text', file_data_gw)
     root_mapper.getSubMapper('OFS.DTMLMethod.DTMLMethod').setGateway(g)
     
     # dtml document gateway
-    g = CompositeGateway(base_p)
+    g = gateways.CompositeGateway(base_p)
     g.addGateway('text', file_data_gw)
     root_mapper.getSubMapper('OFS.DTMLDocument.DTMLDocument').setGateway(g)
 
     # zsqlmethod mapper
-    g = CompositeGateway(base_p)
+    g = gateways.CompositeGateway(base_p)
     g.addGateway('text', file_data_gw)
     root_mapper.getSubMapper('Products.ZSQLMethods.SQL.SQL').setGateway(g)
 
     # python script mapper
-    g = CompositeGateway(base)
+    g = gateways.CompositeGateway(base)
     g.addGateway('body', file_data_gw)
     root_mapper.getSubMapper('PythonScript').setGateway(g)
 
     # file gateway
-    g = CompositeGateway(base_p)
+    g = gateways.CompositeGateway(base_p)
     g.addGateway('data', file_data_gw)
     root_mapper.getSubMapper('OFS.Image.File').setGateway(g)
 
@@ -105,21 +106,21 @@
     root_mapper.getSubMapper('OFS.Image.Image').setGateway(g)
 
     # user folder gateway
-    g = CompositeGateway(base)
-    g.addGateway('data', SQLUserList(conn))
+    g = gateways.CompositeGateway(base)
+    g.addGateway('data', userlist_gw)
     root_mapper.getSubMapper('AccessControl.User.UserFolder').setGateway(g)
 
     # anyfolder object gateway
-    g = CompositeGateway(base_p)
+    g = gateways.CompositeGateway(base_p)
     g.addGateway('items', folder_items_gw)
     root_mapper.getSubMapper('anyfolder').setGateway(g)
 
     # anyfile object gateway
-    g = CompositeGateway(base_p)
+    g = gateways.CompositeGateway(base_p)
     root_mapper.getSubMapper('anyfile').setGateway(g)
 
     # application gateway
-    g = CompositeGateway(base_p)
+    g = gateways.CompositeGateway(base_p)
     g.removeGateway('id')
     g.addGateway('items', folder_items_gw)
     root_mapper.getSubMapper('OFS.Application.Application').setGateway(g)
@@ -136,7 +137,7 @@
     factory=apelib.zope2.fsmapper.createMapper
     """
     # The "volatile" argument is ignored.
-    from apelib.sql.pg import PsycopgConnection
-    conn = PsycopgConnection(params, table_prefix)
+    from apelib.sql import pg
+    conn = pg.PsycopgConnection(params, table_prefix)
     return createSQLMapper(conn)[:2]