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

Shane Hathaway shane@zope.com
Tue, 29 Apr 2003 18:12:23 -0400


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

Modified Files:
	fsmapper.py sqlmapper.py 
Log Message:
- Added IGatewayEvent, the base interface for ILoadEvent and
IStoreEvent.

- Filesystem gateways no longer refer directly to a connection.  They
get the connection from the event.  This is to permit replacing the
connection with a zip/tar file reader/writer or some other interesting
thing.

- Added checkConnection() to gateways for checking the connection
configuration early.

- Added ConfigurationError and changed some places that were raising
RuntimeError to raise ConfigurationError instead.

- Changed some calls to getKeyChain()[-1] to simply getKey()

- Updated module import style in some places

- Various other style improvements




=== Products/Ape/lib/apelib/zope2/fsmapper.py 1.1 => 1.2 ===
--- Products/Ape/lib/apelib/zope2/fsmapper.py:1.1	Wed Apr  9 23:09:58 2003
+++ Products/Ape/lib/apelib/zope2/fsmapper.py	Tue Apr 29 18:11:52 2003
@@ -22,39 +22,37 @@
 from apelib.zope2 import basemapper
 
 
-def createMapper(basepath, volatile=1, **kw):
+def createAbstractMapper():
     """Object mapper factory.
 
     Usage in database configuration file:
     factory=apelib.zope2.fsmapper.createMapper
     """
-    # The "volatile" argument is ignored.
-    conn = connection.FSConnection(basepath, **kw)
     root_mapper = basemapper.createZope2Mapper('/', 0)
     root_mapper.getClassifier().setGateway(
-        classification.FSClassificationSection(conn))
+        classification.FSClassificationSection())
     root_mapper.setKeychainGenerator(keygen.PathKeychainGenerator())
-    file_binary_data = structure.FSFileData(conn, text=0)
-    file_text_data = structure.FSFileData(conn, text=1)
+    file_binary_data = structure.FSFileData(text=0)
+    file_text_data = structure.FSFileData(text=1)
 
     # abstract base gateway
     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))
+    g.addGateway('modtime', structure.FSModTime())
+    g.addGateway('remainder', properties.FSSectionData('remainder'))
+    g.addGateway('security', security.FSSecurityAttributes())
     root_mapper.getSubMapper('base').setGateway(g)
     base = g
 
     # abstract base gateway with properties
     g = gateways.CompositeGateway(base)
-    g.addGateway('properties', properties.FSProperties(conn))
+    g.addGateway('properties', properties.FSProperties())
     root_mapper.getSubMapper('base_p').setGateway(g)
     base_p = g
 
     # folder gateway
     g = gateways.CompositeGateway(base_p)
-    g.addGateway('items', structure.FSDirectoryItems(conn))
+    g.addGateway('items', structure.FSDirectoryItems())
     root_mapper.getSubMapper('OFS.Folder.Folder').setGateway(g)
 
     # page template gateway
@@ -75,8 +73,7 @@
     # zsqlmethod mapper
     g = gateways.CompositeGateway(base)
     g.addGateway('text', file_text_data)
-    g.addGateway('properties', properties.FSProperties(
-        conn, 'ZSQL Properties'), 1)
+    g.addGateway('properties', properties.FSProperties('ZSQL Properties'), 1)
     root_mapper.getSubMapper('Products.ZSQLMethods.SQL.SQL').setGateway(g)
 
     # python script mapper
@@ -94,12 +91,12 @@
 
     # user folder gateway
     g = gateways.CompositeGateway(base)
-    g.addGateway('data', security.FSUserList(conn))
+    g.addGateway('data', security.FSUserList())
     root_mapper.getSubMapper('AccessControl.User.UserFolder').setGateway(g)
 
     # anyfolder object gateway
     g = gateways.CompositeGateway(base_p)
-    g.addGateway('items', structure.FSDirectoryItems(conn))
+    g.addGateway('items', structure.FSDirectoryItems())
     root_mapper.getSubMapper('anyfolder').setGateway(g)
 
     # anyfile object gateway
@@ -110,10 +107,17 @@
     # application gateway
     g = gateways.CompositeGateway(base_p)
     g.removeGateway('id')
-    g.addGateway('items', structure.FSDirectoryItems(conn))
+    g.addGateway('items', structure.FSDirectoryItems())
     root_mapper.getSubMapper('OFS.Application.Application').setGateway(g)
 
     root_mapper.checkConfiguration()
 
-    return root_mapper, [conn]
+    return root_mapper
+
+
+def createMapper(basepath, **kw):
+    """Returns (mapper, { name -> connection })"""
+    mapper = createAbstractMapper()
+    conn = connection.FSConnection(basepath, **kw)
+    return mapper, {'fs': conn}
 


=== Products/Ape/lib/apelib/zope2/sqlmapper.py 1.2 => 1.3 ===
--- Products/Ape/lib/apelib/zope2/sqlmapper.py:1.2	Sat Apr 12 16:56:27 2003
+++ Products/Ape/lib/apelib/zope2/sqlmapper.py	Tue Apr 29 18:11:52 2003
@@ -128,7 +128,7 @@
 
     root_mapper.checkConfiguration()
 
-    return root_mapper, [conn], gws
+    return root_mapper, {'db': conn}, gws
 
 
 def createMapper(module_name, params='', kwparams='',