[Zope-Checkins] SVN: Zope/branches/haufe-legacy-integration/ - Launchpad #373583: ZODBMountPoint - fixed broken mount support and

Andreas Jung andreas at andreas-jung.com
Sun May 10 11:58:45 EDT 2009


Log message for revision 99825:
  - Launchpad #373583: ZODBMountPoint - fixed broken mount support and 
    extended the test suite.
  

Changed:
  U   Zope/branches/haufe-legacy-integration/doc/CHANGES.rst
  U   Zope/branches/haufe-legacy-integration/src/Products/ZODBMountPoint/MountedObject.py
  U   Zope/branches/haufe-legacy-integration/src/Products/ZODBMountPoint/tests/testMountPoint.py

-=-
Modified: Zope/branches/haufe-legacy-integration/doc/CHANGES.rst
===================================================================
--- Zope/branches/haufe-legacy-integration/doc/CHANGES.rst	2009-05-10 15:33:08 UTC (rev 99824)
+++ Zope/branches/haufe-legacy-integration/doc/CHANGES.rst	2009-05-10 15:58:44 UTC (rev 99825)
@@ -23,6 +23,9 @@
 Features Added
 ++++++++++++++
 
+- Launchpad #373583: ZODBMountPoint - fixed broken mount support and 
+  extended the test suite.
+
 - Launchpad #373621: catching and logging exceptions that could cause
   leaking of worker threads.
 

Modified: Zope/branches/haufe-legacy-integration/src/Products/ZODBMountPoint/MountedObject.py
===================================================================
--- Zope/branches/haufe-legacy-integration/src/Products/ZODBMountPoint/MountedObject.py	2009-05-10 15:33:08 UTC (rev 99824)
+++ Zope/branches/haufe-legacy-integration/src/Products/ZODBMountPoint/MountedObject.py	2009-05-10 15:58:44 UTC (rev 99825)
@@ -59,9 +59,7 @@
         factory = guarded_getattr(dispatcher, 'manage_addFolder')
         factory(id)
         o = context.restrictedTraverse(id)
-        # Commit a subtransaction to assign the new object to
-        # the correct database.
-        transaction.savepoint(optimistic=True)
+        context._p_jar.add(o.aq_base)
         return o
 
     def traverseOrConstruct(self, path, omit_final=0):

Modified: Zope/branches/haufe-legacy-integration/src/Products/ZODBMountPoint/tests/testMountPoint.py
===================================================================
--- Zope/branches/haufe-legacy-integration/src/Products/ZODBMountPoint/tests/testMountPoint.py	2009-05-10 15:33:08 UTC (rev 99824)
+++ Zope/branches/haufe-legacy-integration/src/Products/ZODBMountPoint/tests/testMountPoint.py	2009-05-10 15:58:44 UTC (rev 99825)
@@ -83,6 +83,7 @@
         databases = [TestDBConfig('test_main.fs', ['/']).getDB(),
                      TestDBConfig('test_mount1.fs', ['/mount1']).getDB(),
                      TestDBConfig('test_mount2.fs', ['/mount2']).getDB(),
+                     TestDBConfig('test_mount3.fs', ['/i/mount3']).getDB(),
                      ]
         mount_points = {}
         mount_factories = {}
@@ -102,13 +103,21 @@
         root = conn.root()
         root['Application'] = app = Application()
         self.app = app
+        install_products(app, 'ZCatalog', 'PluginIndexes', 'OFSP')
+        # login
+        from AccessControl.User import system
+        from AccessControl.SecurityManagement import newSecurityManager
+        newSecurityManager(None, system)
         transaction.commit()  # Get app._p_jar set
-        manage_addMounts(app, ('/mount1', '/mount2'))
+        manage_addMounts(app, ('/mount1', '/mount2', '/i/mount3'))
         transaction.commit()  # Get the mount points ready
 
 
 
     def tearDown(self):
+        # logout
+        from AccessControl.SecurityManagement import noSecurityManager
+        noSecurityManager()
         App.config.setConfiguration(original_config)
         transaction.abort()
         self.app._p_jar.close()
@@ -120,6 +129,7 @@
     def testRead(self):
         self.assertEqual(self.app.mount1.id, 'mount1')
         self.assertEqual(self.app.mount2.id, 'mount2')
+        self.assertEqual(self.app.i.mount3.id, 'mount3')
 
     def testWrite(self):
         app = self.app
@@ -144,6 +154,7 @@
         self.assertEqual(getMountPoint(self.app.mount1)._path, '/mount1')
         self.assert_(getMountPoint(self.app.mount2) is not None)
         self.assertEqual(getMountPoint(self.app.mount2)._path, '/mount2')
+        self.assertEqual(getMountPoint(self.app.i.mount3)._path, '/i/mount3')
         del self.app.mount2
         self.app.mount2 = Folder()
         self.app.mount2.id = 'mount2'
@@ -160,8 +171,13 @@
                     {'status': 'Ok',
                      'path': '/mount2',
                      'name': 'test_mount2.fs',
-                     'exists': 1}]
-        self.assertEqual(expected, status)
+                     'exists': 1},
+                    {'status': 'Ok',
+                     'path': '/i/mount3',
+                     'name': 'test_mount3.fs',
+                     'exists': 1},
+                    ]
+        self.assertEqual(sorted(expected), sorted(status))
         del self.app.mount2
         status = manage_getMountStatus(self.app)
         expected = [{'status': 'Ok',
@@ -171,8 +187,14 @@
                     {'status': 'Ready to create',
                      'path': '/mount2',
                      'name': 'test_mount2.fs',
-                     'exists': 0}]
-        self.assertEqual(expected, status)
+                     'exists': 0},
+                    {'status': 'Ok',
+                     'path': '/i/mount3',
+                     'name': 'test_mount3.fs',
+                     'exists': 1},
+
+                    ]
+        self.assertEqual(sorted(expected), sorted(status))
         self.app.mount2 = Folder('mount2')
         status = manage_getMountStatus(self.app)
         expected = [{'status': 'Ok',
@@ -182,8 +204,13 @@
                     {'status': '** Something is in the way **',
                      'path': '/mount2',
                      'name': 'test_mount2.fs',
-                     'exists': 1}]
-        self.assertEqual(expected, status)
+                     'exists': 1},
+                    {'status': 'Ok',
+                     'path': '/i/mount3',
+                     'name': 'test_mount3.fs',
+                     'exists': 1},
+                    ]
+        self.assertEqual(sorted(expected), sorted(status))
 
     def test_close(self):
         app = self.app
@@ -192,6 +219,7 @@
         app.a3 = '3'
         conn1 = app.mount1._p_jar
         conn2 = app.mount2._p_jar
+        conn3 = app.i.mount3._p_jar
         transaction.abort()
         # Close the main connection
         app._p_jar.close()
@@ -199,8 +227,24 @@
         # Check that secondary connections have been closed too
         self.assertEqual(conn1.opened, None)
         self.assertEqual(conn2.opened, None)
+        self.assertEqual(conn3.opened, None)
 
+def install_products(app, *prod):
+    """auxiliary function to install products *prod* (by names)."""
+    from OFS.Application import get_folder_permissions, get_products, install_product
 
+    folder_permissions = get_folder_permissions()
+    meta_types=[]
+    done={}
+    products = get_products()
+    for priority, product_name, index, product_dir in products:
+        if product_name not in prod or product_name in done: continue
+        done[product_name]=1
+        install_product(app, product_dir, product_name, meta_types,
+                        folder_permissions, raise_exc=True)
+        
+
+
 def test_suite():
     return unittest.makeSuite(MountingTests, 'test')
 



More information about the Zope-Checkins mailing list