[Zope-Checkins] SVN: Zope/trunk/ No longer opens a zodb connection every time a ProductDispatcher is looked up, forward ported from zope 2.10 branch r72990 and five 1.5 branch r72986.
Log message for revision 72991: No longer opens a zodb connection every time a ProductDispatcher is looked up, forward ported from zope 2.10 branch r72990 and five 1.5 branch r72986. Changed: U Zope/trunk/doc/CHANGES.txt U Zope/trunk/lib/python/App/FactoryDispatcher.py U Zope/trunk/lib/python/Products/Five/fiveconfigure.py U Zope/trunk/lib/python/Products/Five/tests/test_registerpackage.py -=- Modified: Zope/trunk/doc/CHANGES.txt === --- Zope/trunk/doc/CHANGES.txt 2007-03-05 14:20:58 UTC (rev 72990) +++ Zope/trunk/doc/CHANGES.txt 2007-03-05 14:43:23 UTC (rev 72991) @@ -82,6 +82,9 @@ Bugs Fixed + - No longer opens a zodb connection every time a ProductDispatcher +is looked up. + - PageTemplate/ZRPythonExpr.py: expressions represented as unicode string caused UnicodeDecodeErrors. Modified: Zope/trunk/lib/python/App/FactoryDispatcher.py === --- Zope/trunk/lib/python/App/FactoryDispatcher.py 2007-03-05 14:20:58 UTC (rev 72990) +++ Zope/trunk/lib/python/App/FactoryDispatcher.py 2007-03-05 14:43:23 UTC (rev 72991) @@ -26,32 +26,15 @@ zope2 packages and those without the Products namespace package. """ -old_product_packages = {} +packages = {} for x in dir(Products): m = getattr(Products, x) if isinstance(m, types.ModuleType): -old_product_packages[x] = m +packages[x] = m + +for m in getattr(Products, '_registered_packages', []): +packages[m.__name__] = m -packages = {} -app = Zope2.app() -try: -products = app.Control_Panel.Products - -for product_id in products.objectIds(): -product = products[product_id] -if hasattr(product, 'package_name'): -pos = product.package_name.rfind('.') -if pos > -1: -packages[product_id] = __import__(product.package_name, - globals(), {}, - product.package_name[pos+1:]) -else: -packages[product_id] = __import__(product.package_name) -elif old_product_packages.has_key(product_id): -packages[product_id] = old_product_packages[product_id] -finally: -app._p_jar.close() - return packages class ProductDispatcher(Acquisition.Implicit): Modified: Zope/trunk/lib/python/Products/Five/fiveconfigure.py === --- Zope/trunk/lib/python/Products/Five/fiveconfigure.py2007-03-05 14:20:58 UTC (rev 72990) +++ Zope/trunk/lib/python/Products/Five/fiveconfigure.py2007-03-05 14:43:23 UTC (rev 72991) @@ -218,6 +218,11 @@ if init_func is not None: newContext = ProductContext(product, app, module_) init_func(newContext) + +registered_packages = getattr(Products, '_registered_packages', None) +if registered_packages is None: +registered_packages = Products._registered_packages = [] +registered_packages.append(module_) finally: try: import transaction Modified: Zope/trunk/lib/python/Products/Five/tests/test_registerpackage.py === --- Zope/trunk/lib/python/Products/Five/tests/test_registerpackage.py 2007-03-05 14:20:58 UTC (rev 72990) +++ Zope/trunk/lib/python/Products/Five/tests/test_registerpackage.py 2007-03-05 14:43:23 UTC (rev 72991) @@ -65,7 +65,11 @@ >>> 'pythonproduct2' in product_listing True +Make sure it also shows up in ``Products._registered_packages``. + >>> [x.__name__ for x in getattr(Products, '_registered_packages', [])] + ['pythonproduct2'] + Clean up: >>> tearDown() ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.10/ No longer opens a zodb connection every time a ProductDispatcher is looked up.
Log message for revision 72990: No longer opens a zodb connection every time a ProductDispatcher is looked up. Changed: U Zope/branches/2.10/doc/CHANGES.txt U Zope/branches/2.10/lib/python/App/FactoryDispatcher.py _U Zope/branches/2.10/lib/python/Products/ -=- Modified: Zope/branches/2.10/doc/CHANGES.txt === --- Zope/branches/2.10/doc/CHANGES.txt 2007-03-05 14:14:15 UTC (rev 72989) +++ Zope/branches/2.10/doc/CHANGES.txt 2007-03-05 14:20:58 UTC (rev 72990) @@ -8,6 +8,9 @@ Bugs fixed + - No longer opens a zodb connection every time a ProductDispatcher +is looked up. + - Collector #2288: @ and + should not be quoted when forming request URLs in BaseRequest and HTTPRequest Modified: Zope/branches/2.10/lib/python/App/FactoryDispatcher.py === --- Zope/branches/2.10/lib/python/App/FactoryDispatcher.py 2007-03-05 14:14:15 UTC (rev 72989) +++ Zope/branches/2.10/lib/python/App/FactoryDispatcher.py 2007-03-05 14:20:58 UTC (rev 72990) @@ -26,32 +26,15 @@ zope2 packages and those without the Products namespace package. """ -old_product_packages = {} +packages = {} for x in dir(Products): m = getattr(Products, x) if isinstance(m, types.ModuleType): -old_product_packages[x] = m +packages[x] = m + +for m in getattr(Products, '_registered_packages', []): +packages[m.__name__] = m -packages = {} -app = Zope2.app() -try: -products = app.Control_Panel.Products - -for product_id in products.objectIds(): -product = products[product_id] -if hasattr(product, 'package_name'): -pos = product.package_name.rfind('.') -if pos > -1: -packages[product_id] = __import__(product.package_name, - globals(), {}, - product.package_name[pos+1:]) -else: -packages[product_id] = __import__(product.package_name) -elif old_product_packages.has_key(product_id): -packages[product_id] = old_product_packages[product_id] -finally: -app._p_jar.close() - return packages class ProductDispatcher(Acquisition.Implicit): Property changes on: Zope/branches/2.10/lib/python/Products ___ Name: svn:externals - Fivesvn://svn.zope.org/repos/main/Products.Five/tags/1.5.2 + Five svn://svn.zope.org/repos/main/Products.Five/tags/1.5.2-plus-registerPackage-fix ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Products.Five/tags/1.5.2-plus-registerPackage-fix/ Tag to map over to zope2 external in between releases.
Log message for revision 72989: Tag to map over to zope2 external in between releases. Changed: A Products.Five/tags/1.5.2-plus-registerPackage-fix/ -=- Copied: Products.Five/tags/1.5.2-plus-registerPackage-fix (from rev 72988, Products.Five/branches/1.5) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Products.Five/branches/1.5/ Added change to registerPackage directive so that it stores the newly
Log message for revision 72986: Added change to registerPackage directive so that it stores the newly registered packages on the Products package object for faster reference. This means code that looks this up (ie Zope2's FactoryDispatcher) no longer has to open a zodb connection each time. Changed: U Products.Five/branches/1.5/CHANGES.txt U Products.Five/branches/1.5/fiveconfigure.py U Products.Five/branches/1.5/tests/test_registerpackage.py -=- Modified: Products.Five/branches/1.5/CHANGES.txt === --- Products.Five/branches/1.5/CHANGES.txt 2007-03-05 12:55:44 UTC (rev 72985) +++ Products.Five/branches/1.5/CHANGES.txt 2007-03-05 13:07:27 UTC (rev 72986) @@ -2,6 +2,14 @@ Five Changes +Five 1.5.x (svn/unreleased) +=== + +* Added change to registerPackage directive so that it stores the newly + registered packages on the Products package object for faster reference. + This means code that looks this up (ie Zope2's FactoryDispatcher) no longer + has to open a zodb connection each time. + Five 1.5.2 (2007-01-10) === Modified: Products.Five/branches/1.5/fiveconfigure.py === --- Products.Five/branches/1.5/fiveconfigure.py 2007-03-05 12:55:44 UTC (rev 72985) +++ Products.Five/branches/1.5/fiveconfigure.py 2007-03-05 13:07:27 UTC (rev 72986) @@ -218,6 +218,11 @@ if init_func is not None: newContext = ProductContext(product, app, module_) init_func(newContext) + +registered_packages = getattr(Products, '_registered_packages', None) +if registered_packages is None: +registered_packages = Products._registered_packages = [] +registered_packages.append(module_) finally: try: import transaction Modified: Products.Five/branches/1.5/tests/test_registerpackage.py === --- Products.Five/branches/1.5/tests/test_registerpackage.py2007-03-05 12:55:44 UTC (rev 72985) +++ Products.Five/branches/1.5/tests/test_registerpackage.py2007-03-05 13:07:27 UTC (rev 72986) @@ -65,7 +65,11 @@ >>> 'pythonproduct2' in product_listing True +Make sure it also shows up in ``Products._registered_packages``. + >>> [x.__name__ for x in getattr(Products, '_registered_packages', [])] + ['pythonproduct2'] + Clean up: >>> tearDown() ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins