CVS: Products/Basket - __init__.py:1.4

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-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):

_______________________________________________
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.