[z3-checkins] r22184 - in
z3/Five/branch/rocky-products-less-product-loading: . tests
rocky at codespeak.net
rocky at codespeak.net
Sat Jan 14 23:35:45 CET 2006
Author: rocky
Date: Sat Jan 14 23:35:16 2006
New Revision: 22184
Modified:
z3/Five/branch/rocky-products-less-product-loading/ (props changed)
z3/Five/branch/rocky-products-less-product-loading/pythonproducts.py
z3/Five/branch/rocky-products-less-product-loading/tests/test_pythonproducts.py
Log:
Removed the requirement for initialize to have to exist. If it does exist, though, it will be invoked.
Modified: z3/Five/branch/rocky-products-less-product-loading/pythonproducts.py
==============================================================================
--- z3/Five/branch/rocky-products-less-product-loading/pythonproducts.py (original)
+++ z3/Five/branch/rocky-products-less-product-loading/pythonproducts.py Sat Jan 14 23:35:16 2006
@@ -56,10 +56,6 @@
"supports filesystem based pure python packages")
- if not hasattr(module_, 'initialize'):
- raise AttributeError("The module '%s' requires a Zope 2 style " \
- "initialize function" % module_.__name__)
-
product = initializeProduct(module_,
module_.__name__,
module_.__path__[0],
@@ -67,8 +63,10 @@
product.package_name = module_.__name__
- newContext = ProductContext(product, _zope_app, module_)
- module_.initialize(newContext)
+ if hasattr(module_, 'initialize') and \
+ hasattr(module_.initialize, '__call__'):
+ newContext = ProductContext(product, _zope_app, module_)
+ module_.initialize(newContext)
def setup_python_products(context):
"""Initialize the python-packages-as-products logic
Modified: z3/Five/branch/rocky-products-less-product-loading/tests/test_pythonproducts.py
==============================================================================
--- z3/Five/branch/rocky-products-less-product-loading/tests/test_pythonproducts.py (original)
+++ z3/Five/branch/rocky-products-less-product-loading/tests/test_pythonproducts.py Sat Jan 14 23:35:16 2006
@@ -39,11 +39,6 @@
...
TypeError: The package argument must either be an instance of basestring or types.ModuleType
- >>> pythonproducts.register_python_product('Products.Five.tests.adapters')
- Traceback (most recent call last):
- ...
- AttributeError: The module 'Products' requires a Zope 2 style initialize function
-
>>> pythonproducts.register_python_product(zope2module)
Traceback (most recent call last):
...
More information about the z3-checkins
mailing list