[Checkins] SVN: z3c.autoinclude/branches/adding-salt/src/z3c/autoinclude/ rework entry point spelling to ignore ep name and treat the broadcast object as the dotted module name of the base platform to plug into, per martijn's preferred syntax.

Ethan Jucovy ejucovy at openplans.org
Mon Mar 24 18:20:03 EDT 2008


Log message for revision 84909:
  rework entry point spelling to ignore ep name and treat the broadcast object as the dotted module name of the base platform to plug into, per martijn's preferred syntax.

Changed:
  U   z3c.autoinclude/branches/adding-salt/src/z3c/autoinclude/README.txt
  U   z3c.autoinclude/branches/adding-salt/src/z3c/autoinclude/plugin.py
  U   z3c.autoinclude/branches/adding-salt/src/z3c/autoinclude/tests/FooPackage/setup.py
  U   z3c.autoinclude/branches/adding-salt/src/z3c/autoinclude/tests/TestDirective/setup.py

-=-
Modified: z3c.autoinclude/branches/adding-salt/src/z3c/autoinclude/README.txt
===================================================================
--- z3c.autoinclude/branches/adding-salt/src/z3c/autoinclude/README.txt	2008-03-24 22:17:32 UTC (rev 84908)
+++ z3c.autoinclude/branches/adding-salt/src/z3c/autoinclude/README.txt	2008-03-24 22:19:53 UTC (rev 84909)
@@ -211,12 +211,12 @@
     ...   elif dist.project_name == 'BasePackage':
     ...     base_dist = dist
 
-Given a module name, we can ask for modules which have been broadcast
-as plugging into that module via entry points::
+Given a module name, we can ask for distributions which have been broadcast
+themselves as plugging into that module via entry points::
 
     >>> from z3c.autoinclude.plugin import find_plugins
     >>> sorted(find_plugins('basepackage'))
-    ['foo', 'testdirective']
+    [FooPackage 0.0 (...), TestDirective 0.0 (...)]
 
 Armed with a valid module name we can find the ZCML files within it
 which must be loaded::
@@ -232,7 +232,13 @@
     >>> zcml_to_include('foo', ['meta.zcml'])
     []
 
-Between these two functions we can now get a dictionary of all
+Finally, we know how to get a list of all module dottednames within
+a distribution::
+
+    >>> IncludeFinder(foo_dist).dottedNames()
+    ['foo']
+
+So between these functions we can now get a dictionary of all
 extension modules which must be loaded for each ZCML group given
 a base platform::
 

Modified: z3c.autoinclude/branches/adding-salt/src/z3c/autoinclude/plugin.py
===================================================================
--- z3c.autoinclude/branches/adding-salt/src/z3c/autoinclude/plugin.py	2008-03-24 22:17:32 UTC (rev 84908)
+++ z3c.autoinclude/branches/adding-salt/src/z3c/autoinclude/plugin.py	2008-03-24 22:19:53 UTC (rev 84909)
@@ -1,12 +1,13 @@
 import os
 from pkg_resources import iter_entry_points
 from pkg_resources import resource_filename
+from z3c.autoinclude.include import IncludeFinder
 
 def find_plugins(dotted_name):
     plugins = []
     for ep in iter_entry_points('z3c.autoinclude.plugin'):
-        if ep.name == dotted_name:
-            plugins.append(ep.module_name)
+        if ep.module_name == dotted_name:
+            plugins.append(ep.dist)
     return plugins
 
 def zcml_to_include(dotted_name, zcmlgroups=None):
@@ -24,8 +25,10 @@
 def plugins_to_include(platform_dottedname, zcmlgroups=None):
     includable_info = {}
 
-    for plugin_dottedname in find_plugins(platform_dottedname):
-        groups = zcml_to_include(plugin_dottedname, zcmlgroups)
-        for group in groups:
-            includable_info.setdefault(group, []).append(plugin_dottedname)
+    for plugin_distribution in find_plugins(platform_dottedname):
+        include_finder = IncludeFinder(plugin_distribution)
+        for plugin_dottedname in include_finder.dottedNames():
+            groups = zcml_to_include(plugin_dottedname, zcmlgroups)
+            for group in groups:
+                includable_info.setdefault(group, []).append(plugin_dottedname)
     return includable_info

Modified: z3c.autoinclude/branches/adding-salt/src/z3c/autoinclude/tests/FooPackage/setup.py
===================================================================
--- z3c.autoinclude/branches/adding-salt/src/z3c/autoinclude/tests/FooPackage/setup.py	2008-03-24 22:17:32 UTC (rev 84908)
+++ z3c.autoinclude/branches/adding-salt/src/z3c/autoinclude/tests/FooPackage/setup.py	2008-03-24 22:19:53 UTC (rev 84909)
@@ -24,6 +24,6 @@
       entry_points="""
       # -*- Entry points: -*-
       [z3c.autoinclude.plugin]
-      basepackage = foo
+      target = basepackage
       """,
       )

Modified: z3c.autoinclude/branches/adding-salt/src/z3c/autoinclude/tests/TestDirective/setup.py
===================================================================
--- z3c.autoinclude/branches/adding-salt/src/z3c/autoinclude/tests/TestDirective/setup.py	2008-03-24 22:17:32 UTC (rev 84908)
+++ z3c.autoinclude/branches/adding-salt/src/z3c/autoinclude/tests/TestDirective/setup.py	2008-03-24 22:19:53 UTC (rev 84909)
@@ -24,6 +24,6 @@
       entry_points="""
       # -*- Entry points: -*-
       [z3c.autoinclude.plugin]
-      basepackage = testdirective
+      target = basepackage
       """,
       )



More information about the Checkins mailing list