[Zope-Checkins] SVN: Products.Five/trunk/ Fixed up an issue where an open zodb connection wasn't geting closed properly ... also reinstated a previously-failing (but no longer) test now that the zodb connection handling is working properly.

Rocky Burt rocky at serverzen.com
Thu May 4 14:20:34 EDT 2006


Log message for revision 67968:
  Fixed up an issue where an open zodb connection wasn't geting closed properly ... also reinstated a previously-failing (but no longer) test now that the zodb connection handling is working properly.

Changed:
  U   Products.Five/trunk/fiveconfigure.py
  U   Products.Five/trunk/tests/test_registerpackage.py

-=-
Modified: Products.Five/trunk/fiveconfigure.py
===================================================================
--- Products.Five/trunk/fiveconfigure.py	2006-05-04 17:17:04 UTC (rev 67967)
+++ Products.Five/trunk/fiveconfigure.py	2006-05-04 18:20:34 UTC (rev 67968)
@@ -211,18 +211,24 @@
                          "package must be filesystem based")
     
     app = Zope2.app()
-    product = initializeProduct(module_, 
-                                module_.__name__, 
-                                module_.__path__[0],
-                                app)
+    try:
+        product = initializeProduct(module_, 
+                                    module_.__name__, 
+                                    module_.__path__[0],
+                                    app)
 
-    product.package_name = module_.__name__
+        product.package_name = module_.__name__
 
-    if init_func is not None:
-        newContext = ProductContext(product, app, module_)
-        init_func(newContext)
+        if init_func is not None:
+            newContext = ProductContext(product, app, module_)
+            init_func(newContext)
+    finally:
+        try:
+            import transaction
+            transaction.commit()
+        finally:
+            app._p_jar.close()
 
-
 def registerPackage(_context, package, initialize=None):
     """ZCML directive function for registering a python package product
     """

Modified: Products.Five/trunk/tests/test_registerpackage.py
===================================================================
--- Products.Five/trunk/tests/test_registerpackage.py	2006-05-04 17:17:04 UTC (rev 67967)
+++ Products.Five/trunk/tests/test_registerpackage.py	2006-05-04 18:20:34 UTC (rev 67968)
@@ -50,7 +50,22 @@
       ... </configure>'''
       >>> zcml.load_string(configure_zcml)
       pythonproduct2 initialized
+
       
+    Test to see if the pythonproduct2 python package actually gets setup
+    as a zope2 product in the Control Panel.
+
+      >>> product_listing = []
+      >>> import Zope2
+      >>> app = Zope2.app()
+      >>> try:
+      ...    product_listing = app.Control_Panel.Products.objectIds()
+      ... finally:
+      ...     app._p_jar.close()
+      >>> 'pythonproduct2' in product_listing
+      True
+
+
     Clean up:
 
       >>> tearDown()



More information about the Zope-Checkins mailing list