Commit 273d4d70 authored by Hanno Schlichting's avatar Hanno Schlichting

Changed policy on handling exceptions during ZCML parsing in ``Products``. We...

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.
parent dda0b10f
...@@ -19,6 +19,9 @@ Bugs Fixed ...@@ -19,6 +19,9 @@ Bugs Fixed
Features Added 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. - Added a new BooleanIndex to the standard PluginIndexes.
- Update to Zope Toolkit 1.0c1. - Update to Zope Toolkit 1.0c1.
......
...@@ -31,14 +31,6 @@ def findProducts(): ...@@ -31,14 +31,6 @@ def findProducts():
return products 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): def loadProducts(_context, file=None, files=None, package=None):
if file is None: if file is None:
# set the default # set the default
...@@ -51,10 +43,7 @@ def loadProducts(_context, file=None, files=None, package=None): ...@@ -51,10 +43,7 @@ def loadProducts(_context, file=None, files=None, package=None):
for product in findProducts(): for product in findProducts():
zcml = os.path.join(os.path.dirname(product.__file__), file) zcml = os.path.join(os.path.dirname(product.__file__), file)
if os.path.isfile(zcml): if os.path.isfile(zcml):
try: xmlconfig.include(_context, zcml, package=product)
xmlconfig.include(_context, zcml, package=product)
except: # Yes, really, *any* kind of error.
handleBrokenProduct(product)
def loadProductsOverrides(_context, file=None, files=None, package=None): def loadProductsOverrides(_context, file=None, files=None, package=None):
...@@ -69,10 +58,7 @@ def loadProductsOverrides(_context, file=None, files=None, package=None): ...@@ -69,10 +58,7 @@ def loadProductsOverrides(_context, file=None, files=None, package=None):
for product in findProducts(): for product in findProducts():
zcml = os.path.join(os.path.dirname(product.__file__), file) zcml = os.path.join(os.path.dirname(product.__file__), file)
if os.path.isfile(zcml): if os.path.isfile(zcml):
try: xmlconfig.includeOverrides(_context, zcml, package=product)
xmlconfig.includeOverrides(_context, zcml, package=product)
except: # Yes, really, *any* kind of error.
handleBrokenProduct(product)
def get_registered_packages(): def get_registered_packages():
......
...@@ -16,10 +16,12 @@ ...@@ -16,10 +16,12 @@
These directives are specific to Five and have no equivalents outside of it. These directives are specific to Five and have no equivalents outside of it.
""" """
import logging
import os import os
import glob import glob
import warnings import warnings
from App.config import getConfiguration
from zope.interface import classImplements from zope.interface import classImplements
from zope.component.interface import provideInterface from zope.component.interface import provideInterface
from zope.configuration.exceptions import ConfigurationError from zope.configuration.exceptions import ConfigurationError
...@@ -27,6 +29,8 @@ from zope.publisher.interfaces.browser import IDefaultBrowserLayer ...@@ -27,6 +29,8 @@ from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from Products.Five.browser.metaconfigure import page from Products.Five.browser.metaconfigure import page
logger = logging.getLogger('Products.Five')
def implements(_context, class_, interface): def implements(_context, class_, interface):
warnings.warn('Using <five:implements /> in %s is deprecated. Please use ' warnings.warn('Using <five:implements /> in %s is deprecated. Please use '
...@@ -67,11 +71,18 @@ def pagesFromDirectory(_context, directory, module, for_=None, ...@@ -67,11 +71,18 @@ def pagesFromDirectory(_context, directory, module, for_=None,
layer=layer, for_=for_, template=fname) 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 from zope.deferredimport import deprecated
deprecated("Please import from OFS.metaconfigure", deprecated("Please import from OFS.metaconfigure",
findProducts = 'OFS.metaconfigure:findProducts', findProducts = 'OFS.metaconfigure:findProducts',
handleBrokenProduct = 'OFS.metaconfigure:handleBrokenProduct',
loadProducts = 'OFS.metaconfigure:loadProducts', loadProducts = 'OFS.metaconfigure:loadProducts',
loadProductsOverrides = 'OFS.metaconfigure:loadProductsOverrides', loadProductsOverrides = 'OFS.metaconfigure:loadProductsOverrides',
_register_monkies = 'OFS.metaconfigure:_register_monkies', _register_monkies = 'OFS.metaconfigure:_register_monkies',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment