[Zope-CVS] CVS: Products/Basket - __init__.py:1.4

Chris McDonough chrism at plope.com
Mon Nov 7 16:29:11 EST 2005


Update of /cvs-repository/Products/Basket
In directory cvs.zope.org:/tmp/cvs-serv8294

Modified Files:
	__init__.py 
Log Message:
Use different DWIM to find all Zope packages on the path in product_distributions_by_dwim (don't require a Products namespace package).


=== Products/Basket/__init__.py 1.3 => 1.4 ===
--- Products/Basket/__init__.py:1.3	Mon Nov  7 15:11:02 2005
+++ Products/Basket/__init__.py	Mon Nov  7 16:29:11 2005
@@ -3,6 +3,8 @@
 import pkg_resources
 import inspect
 
+entrypoint_group = 'zope2.initialize'
+
 class Basket(object):
     def __init__(self):
         self.pre_initialized = False
@@ -29,7 +31,7 @@
             pdist_fname = os.path.join(etc, 'PRODUCT_DISTRIBUTIONS.txt')
             self.preinitialize(pdist_fname)
         data = []
-        points = pkg_resources.iter_entry_points('zope2.initialize')
+        points = pkg_resources.iter_entry_points(entrypoint_group)
         meta_types = []
         for point in points:
             initialize = point.load()
@@ -39,16 +41,18 @@
 
     def product_distributions_by_dwim(self):
         environment = pkg_resources.Environment()
-        ns_meta = 'namespace_packages.txt'
+        ns_meta = 'entry_points.txt'
         product_distros = []
         for project_name in environment:
             distributions = environment[project_name]
             for distribution in distributions:
                 if distribution.has_metadata(ns_meta):
-                    packages = distribution.get_metadata(ns_meta)
-                    lines = packages.splitlines()
-                    if 'Products' in lines:
-                        product_distros.append(distribution)
+                    inifile = distribution.get_metadata(ns_meta)
+                    sections = pkg_resources.split_sections(inifile)
+                    for section, content in sections:
+                        if section == entrypoint_group:
+                            product_distros.append(distribution)
+                            break
         return product_distros
 
     def preinitialize(self, pdist_fname=None):



More information about the Zope-CVS mailing list