Log message for revision 116950: Changed policy on handling exceptions during ZCML parsing in ``Products``. We no longer catch any exceptions in non-debug mode. These days most products won't actually do anything useful if their ZCML is not loaded - it's no longer helpful to pretend to get a working instance. We'd rather fail early and visible.
Changed: U Zope/trunk/doc/CHANGES.rst U Zope/trunk/src/OFS/metaconfigure.py U Zope/trunk/src/Products/Five/fiveconfigure.py -=- Modified: Zope/trunk/doc/CHANGES.rst =================================================================== --- Zope/trunk/doc/CHANGES.rst 2010-09-25 22:03:22 UTC (rev 116949) +++ Zope/trunk/doc/CHANGES.rst 2010-09-25 22:12:57 UTC (rev 116950) @@ -19,6 +19,9 @@ Features Added ++++++++++++++ +- Changed policy on handling exceptions during ZCML parsing in ``Products``. + We no longer catch any exceptions in non-debug mode. + - Added a new BooleanIndex to the standard PluginIndexes. - Update to Zope Toolkit 1.0c1. Modified: Zope/trunk/src/OFS/metaconfigure.py =================================================================== --- Zope/trunk/src/OFS/metaconfigure.py 2010-09-25 22:03:22 UTC (rev 116949) +++ Zope/trunk/src/OFS/metaconfigure.py 2010-09-25 22:12:57 UTC (rev 116950) @@ -31,14 +31,6 @@ return products -def handleBrokenProduct(product): - if debug_mode: - # Just reraise the error and let Zope handle it. - raise - # Not debug mode. Zope should continue to load. Print a log message: - logger.exception('Could not import Product %s' % product.__name__) - - def loadProducts(_context, file=None, files=None, package=None): if file is None: # set the default @@ -51,10 +43,7 @@ for product in findProducts(): zcml = os.path.join(os.path.dirname(product.__file__), file) if os.path.isfile(zcml): - try: - xmlconfig.include(_context, zcml, package=product) - except: # Yes, really, *any* kind of error. - handleBrokenProduct(product) + xmlconfig.include(_context, zcml, package=product) def loadProductsOverrides(_context, file=None, files=None, package=None): @@ -69,10 +58,7 @@ for product in findProducts(): zcml = os.path.join(os.path.dirname(product.__file__), file) if os.path.isfile(zcml): - try: - xmlconfig.includeOverrides(_context, zcml, package=product) - except: # Yes, really, *any* kind of error. - handleBrokenProduct(product) + xmlconfig.includeOverrides(_context, zcml, package=product) def get_registered_packages(): Modified: Zope/trunk/src/Products/Five/fiveconfigure.py =================================================================== --- Zope/trunk/src/Products/Five/fiveconfigure.py 2010-09-25 22:03:22 UTC (rev 116949) +++ Zope/trunk/src/Products/Five/fiveconfigure.py 2010-09-25 22:12:57 UTC (rev 116950) @@ -16,10 +16,12 @@ These directives are specific to Five and have no equivalents outside of it. """ +import logging import os import glob import warnings +from App.config import getConfiguration from zope.interface import classImplements from zope.component.interface import provideInterface from zope.configuration.exceptions import ConfigurationError @@ -27,7 +29,9 @@ from Products.Five.browser.metaconfigure import page +logger = logging.getLogger('Products.Five') + def implements(_context, class_, interface): warnings.warn('Using <five:implements /> in %s is deprecated. Please use ' 'the <class class="foo.Bar">' @@ -67,11 +71,18 @@ layer=layer, for_=for_, template=fname) +def handleBrokenProduct(product): + if getConfiguration().debug_mode: + # Just reraise the error and let Zope handle it. + raise + # Not debug mode. Zope should continue to load. Print a log message: + logger.exception('Could not import Product %s' % product.__name__) + + from zope.deferredimport import deprecated deprecated("Please import from OFS.metaconfigure", findProducts = 'OFS.metaconfigure:findProducts', - handleBrokenProduct = 'OFS.metaconfigure:handleBrokenProduct', loadProducts = 'OFS.metaconfigure:loadProducts', loadProductsOverrides = 'OFS.metaconfigure:loadProductsOverrides', _register_monkies = 'OFS.metaconfigure:_register_monkies', _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org https://mail.zope.org/mailman/listinfo/zope-checkins