[Checkins] SVN: hurry.resource/trunk/src/hurry/resource/ Implement entry point mechanism to register libraries. Unfortunately
Martijn Faassen
faassen at startifact.com
Sat Jul 24 08:53:53 EDT 2010
Log message for revision 114986:
Implement entry point mechanism to register libraries. Unfortunately
testing this is really really hard so I'm giving up for now.
Changed:
U hurry.resource/trunk/src/hurry/resource/README.txt
U hurry.resource/trunk/src/hurry/resource/__init__.py
U hurry.resource/trunk/src/hurry/resource/core.py
-=-
Modified: hurry.resource/trunk/src/hurry/resource/README.txt
===================================================================
--- hurry.resource/trunk/src/hurry/resource/README.txt 2010-07-24 10:45:21 UTC (rev 114985)
+++ hurry.resource/trunk/src/hurry/resource/README.txt 2010-07-24 12:53:52 UTC (rev 114986)
@@ -43,6 +43,36 @@
>>> foo.path #doctest: +ELLIPSIS
'.../hurry.resource/src/hurry/resource/dummy'
+Entry points
+============
+
+Libraries can be exposed for registration by whatever web framework
+that hurry.resource is integrated with. This web framework can then
+expose the library path on a URL somewhere. This is done using the
+``hurry.resource.libraries`` entry point. To register ``Library``
+instances ``foo`` and ``bar`` in your package as entry points include
+a section like this in your ``setup.py``::
+
+ entry_points={
+ 'hurry.resource.libraries': [
+ 'foo = mypackage.foomodule:foo',
+ 'bar = mypackage.barmodule:bar',
+ ],
+ }
+
+There is an API to help you obtain all registered libraries::
+
+ >>> from hurry.resource import libraries
+
+Nothing is registered however::
+
+ >>> list(libraries())
+ []
+
+It would be nice to now have some tests that see whether entry points
+actually get picked up so, but that would require an involved test
+setup that we find difficult to construct.
+
Inclusion
=========
Modified: hurry.resource/trunk/src/hurry/resource/__init__.py
===================================================================
--- hurry.resource/trunk/src/hurry/resource/__init__.py 2010-07-24 10:45:21 UTC (rev 114985)
+++ hurry.resource/trunk/src/hurry/resource/__init__.py 2010-07-24 12:53:52 UTC (rev 114986)
@@ -1,4 +1,5 @@
from hurry.resource.core import (Library,
+ libraries,
ResourceInclusion,
GroupInclusion,
NeededInclusions)
Modified: hurry.resource/trunk/src/hurry/resource/core.py
===================================================================
--- hurry.resource/trunk/src/hurry/resource/core.py 2010-07-24 10:45:21 UTC (rev 114985)
+++ hurry.resource/trunk/src/hurry/resource/core.py 2010-07-24 12:53:52 UTC (rev 114986)
@@ -22,6 +22,9 @@
self.name = name
self.path = pkg_resources.resource_filename(__name__, rootpath)
+def libraries():
+ return pkg_resources.iter_entry_points('hurry.resource.libraries')
+
class InclusionBase(object):
implements(interfaces.IInclusion)
More information about the checkins
mailing list