CVS: Products/Basket - __init__.py:1.6

Chris McDonough <[email protected]>
Newsgroups gmane.comp.web.zope.public-cvs
Message-ID <[email protected]>
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

_______________________________________________
Zope-CVS maillist  -  [email protected]
http://mail.zope.org/mailman/listinfo/zope-cvs

Zope CVS instructions: http://dev.zope.org/CVS
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.