[Zope-Checkins] SVN: Zope/trunk/ Added a new API to ``OFS.metaconfigure.get_registered_packages`` which replaces any direct access to ``Products._registered_packages``.
Hanno Schlichting
hannosch at hannosch.eu
Sun Jun 27 09:05:56 EDT 2010
Log message for revision 113927:
Added a new API to ``OFS.metaconfigure.get_registered_packages`` which replaces any direct access to ``Products._registered_packages``.
Changed:
U Zope/trunk/doc/CHANGES.rst
U Zope/trunk/src/App/FactoryDispatcher.py
U Zope/trunk/src/OFS/metaconfigure.py
U Zope/trunk/src/OFS/tests/test_registerpackage.py
-=-
Modified: Zope/trunk/doc/CHANGES.rst
===================================================================
--- Zope/trunk/doc/CHANGES.rst 2010-06-27 12:44:22 UTC (rev 113926)
+++ Zope/trunk/doc/CHANGES.rst 2010-06-27 13:05:55 UTC (rev 113927)
@@ -18,6 +18,9 @@
Features Added
++++++++++++++
+- Added a new API to ``OFS.metaconfigure.get_registered_packages`` which
+ replaces any direct access to ``Products._registered_packages``.
+
- Changed product install so it won't write persistent changes only to abort
them. Instead we don't make any database changes in the first place.
Modified: Zope/trunk/src/App/FactoryDispatcher.py
===================================================================
--- Zope/trunk/src/App/FactoryDispatcher.py 2010-06-27 12:44:22 UTC (rev 113926)
+++ Zope/trunk/src/App/FactoryDispatcher.py 2010-06-27 13:05:55 UTC (rev 113927)
@@ -24,6 +24,7 @@
from Acquisition import aq_base
from Acquisition import Implicit
from ExtensionClass import Base
+from OFS.metaconfigure import get_registered_packages
def _product_packages():
@@ -37,9 +38,9 @@
if isinstance(m, types.ModuleType):
packages[x] = m
- for m in getattr(Products, '_registered_packages', []):
+ for m in get_registered_packages():
packages[m.__name__] = m
-
+
return packages
Modified: Zope/trunk/src/OFS/metaconfigure.py
===================================================================
--- Zope/trunk/src/OFS/metaconfigure.py 2010-06-27 12:44:22 UTC (rev 113926)
+++ Zope/trunk/src/OFS/metaconfigure.py 2010-06-27 13:05:55 UTC (rev 113927)
@@ -71,17 +71,21 @@
handleBrokenProduct(product)
+def get_registered_packages():
+ packages = getattr(Products, '_registered_packages', None)
+ if packages is None:
+ packages = Products._registered_packages = []
+ return packages
+
+
def _registerPackage(module_, init_func=None):
"""Registers the given python package as a Zope 2 style product
"""
-
if not hasattr(module_, '__path__'):
raise ValueError("Must be a package and the " \
"package must be filesystem based")
- registered_packages = getattr(Products, '_registered_packages', None)
- if registered_packages is None:
- registered_packages = Products._registered_packages = []
+ registered_packages = get_registered_packages()
registered_packages.append(module_)
# Delay the actual setup until the usual product loading time in
Modified: Zope/trunk/src/OFS/tests/test_registerpackage.py
===================================================================
--- Zope/trunk/src/OFS/tests/test_registerpackage.py 2010-06-27 12:44:22 UTC (rev 113926)
+++ Zope/trunk/src/OFS/tests/test_registerpackage.py 2010-06-27 13:05:55 UTC (rev 113927)
@@ -56,9 +56,10 @@
>>> install_products(app)
pythonproduct2 initialized
- Make sure it shows up in ``Products._registered_packages``.
+ Make sure it is registered:
- >>> [x.__name__ for x in getattr(Products, '_registered_packages', [])]
+ >>> from OFS.metaconfigure import get_registered_packages
+ >>> [x.__name__ for x in get_registered_packages()]
['pythonproduct2']
Clean up:
More information about the Zope-Checkins
mailing list