[Zope-CVS] CVS: Products/Basket - __init__.py:1.6
Chris McDonough
chrism at plope.com
Mon Nov 7 17:24:14 EST 2005
Update of /cvs-repository/Products/Basket
In directory cvs.zope.org:/tmp/cvs-serv25443
Modified Files:
__init__.py
Log Message:
Find container package using module_name of entry point.
=== Products/Basket/__init__.py 1.5 => 1.6 ===
--- Products/Basket/__init__.py:1.5 Mon Nov 7 16:48:08 2005
+++ Products/Basket/__init__.py Mon Nov 7 17:24:14 2005
@@ -34,8 +34,9 @@
points = pkg_resources.iter_entry_points(entrypoint_group)
meta_types = []
for point in points:
+ package = get_containing_package(point.module_name)
initialize = point.load()
- context = EggProductContext(product, app, package)
+ context = EggProductContext(app, package)
initialize(context)
return data
@@ -70,6 +71,16 @@
for distribution in distributions:
pkg_resources.working_set.add(distribution)
self.pre_initialized = True
+
+def get_containing_package(module_name):
+ __import__(module_name)
+ thing = sys.modules[module_name]
+ if hasattr(thing, '__path__'):
+ return thing
+ new = '.'.join(module_name.split('.')[:-1])
+ if new == module_name:
+ return None
+ return get_containing_package(new)
basket = Basket()
initialize = basket.initialize
More information about the Zope-CVS
mailing list