[Zope-Checkins] SVN: Zope/trunk/ Make the API complete by offering a has_package
Hanno Schlichting
hannosch at hannosch.eu
Sun Jun 27 09:17:08 EDT 2010
Log message for revision 113930:
Make the API complete by offering a has_package
Changed:
U Zope/trunk/doc/CHANGES.rst
U Zope/trunk/src/OFS/metaconfigure.py
U Zope/trunk/src/OFS/tests/test_registerpackage.py
U Zope/trunk/src/Testing/ZopeTestCase/ZopeLite.py
-=-
Modified: Zope/trunk/doc/CHANGES.rst
===================================================================
--- Zope/trunk/doc/CHANGES.rst 2010-06-27 13:12:03 UTC (rev 113929)
+++ Zope/trunk/doc/CHANGES.rst 2010-06-27 13:17:07 UTC (rev 113930)
@@ -18,8 +18,9 @@
Features Added
++++++++++++++
-- Added a new API to ``OFS.metaconfigure.get_registered_packages`` which
- replaces any direct access to ``Products._registered_packages``.
+- Added a new API's ``get_registered_packages, set_registered_packages`` to
+ ``OFS.metaconfigure`` which replace 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/OFS/metaconfigure.py
===================================================================
--- Zope/trunk/src/OFS/metaconfigure.py 2010-06-27 13:12:03 UTC (rev 113929)
+++ Zope/trunk/src/OFS/metaconfigure.py 2010-06-27 13:17:07 UTC (rev 113930)
@@ -82,6 +82,10 @@
_registered_packages = packages
+def has_package(package):
+ return package in [m.__name__ for m in get_registered_packages()]
+
+
def _registerPackage(module_, init_func=None):
"""Registers the given python package as a Zope 2 style product
"""
Modified: Zope/trunk/src/OFS/tests/test_registerpackage.py
===================================================================
--- Zope/trunk/src/OFS/tests/test_registerpackage.py 2010-06-27 13:12:03 UTC (rev 113929)
+++ Zope/trunk/src/OFS/tests/test_registerpackage.py 2010-06-27 13:17:07 UTC (rev 113930)
@@ -58,9 +58,9 @@
Make sure it is registered:
- >>> from OFS.metaconfigure import get_registered_packages
- >>> [x.__name__ for x in get_registered_packages()]
- ['pythonproduct2']
+ >>> from OFS.metaconfigure import has_package
+ >>> has_package('pythonproduct2')
+ True
Clean up:
Modified: Zope/trunk/src/Testing/ZopeTestCase/ZopeLite.py
===================================================================
--- Zope/trunk/src/Testing/ZopeTestCase/ZopeLite.py 2010-06-27 13:12:03 UTC (rev 113929)
+++ Zope/trunk/src/Testing/ZopeTestCase/ZopeLite.py 2010-06-27 13:17:07 UTC (rev 113930)
@@ -191,8 +191,8 @@
def hasPackage(name):
'''Checks if a package has been registered with five:registerPackage.'''
- from OFS.metaconfigure import get_registered_packages
- return name in [m.__name__ for m in get_registered_packages()]
+ from OFS.metaconfigure import has_package
+ return has_package(name)
def installPackage(name, quiet=0):
'''Installs a registered Python package.'''
More information about the Zope-Checkins
mailing list