[Checkins] SVN: hurry.zoperesource/trunk/ Update to work with hurry.resource 0.10 and later. This is done

Martijn Faassen faassen at startifact.com
Thu Jul 29 11:55:12 EDT 2010


Log message for revision 115214:
  Update to work with hurry.resource 0.10 and later. This is done
  by a ZCML directive that gets executed when hurry.resource loads,
  which configures hurry.resource to use the ZCA for its plugins, and
  also publishes all resource libraries as a directory resource.
  

Changed:
  U   hurry.zoperesource/trunk/CHANGES.txt
  U   hurry.zoperesource/trunk/buildout.cfg
  U   hurry.zoperesource/trunk/setup.py
  U   hurry.zoperesource/trunk/src/hurry/zoperesource/README.txt
  U   hurry.zoperesource/trunk/src/hurry/zoperesource/configure.zcml
  A   hurry.zoperesource/trunk/src/hurry/zoperesource/meta.zcml
  U   hurry.zoperesource/trunk/src/hurry/zoperesource/tests/view.py
  A   hurry.zoperesource/trunk/src/hurry/zoperesource/zcml.py

-=-
Modified: hurry.zoperesource/trunk/CHANGES.txt
===================================================================
--- hurry.zoperesource/trunk/CHANGES.txt	2010-07-29 14:35:40 UTC (rev 115213)
+++ hurry.zoperesource/trunk/CHANGES.txt	2010-07-29 15:55:11 UTC (rev 115214)
@@ -4,8 +4,13 @@
 0.6 (unreleased)
 ================
 
-- Nothing changed yet.
+* Update to work with hurry.resource 0.10 and later. This uses the
+  entry point mechanism to configure any libraries.
 
+  Note that this needs hurry.resource-based packages that themselves
+  have been updated to hurry.resource 0.10's way of defining an entry
+  point and including the resource path in the library. See the hurry.resource
+  documentation for more information.
 
 0.5 (2010-07-24)
 ================

Modified: hurry.zoperesource/trunk/buildout.cfg
===================================================================
--- hurry.zoperesource/trunk/buildout.cfg	2010-07-29 14:35:40 UTC (rev 115213)
+++ hurry.zoperesource/trunk/buildout.cfg	2010-07-29 15:55:11 UTC (rev 115214)
@@ -4,7 +4,6 @@
 versions = versions
 
 [versions]
-hurry.resource = 0.4.1
 
 [test]
 recipe = zc.recipe.testrunner

Modified: hurry.zoperesource/trunk/setup.py
===================================================================
--- hurry.zoperesource/trunk/setup.py	2010-07-29 14:35:40 UTC (rev 115213)
+++ hurry.zoperesource/trunk/setup.py	2010-07-29 15:55:11 UTC (rev 115214)
@@ -32,9 +32,10 @@
     install_requires=[
         'setuptools',
         'grokcore.component',
-        'hurry.resource >= 0.4',
+        'hurry.resource >= 0.10',
         'z3c.autoinclude',
         'zope.app.publication',
+        'zope.browserresource',
         'zope.component',
         'zope.interface',
         'zope.publisher',

Modified: hurry.zoperesource/trunk/src/hurry/zoperesource/README.txt
===================================================================
--- hurry.zoperesource/trunk/src/hurry/zoperesource/README.txt	2010-07-29 14:35:40 UTC (rev 115213)
+++ hurry.zoperesource/trunk/src/hurry/zoperesource/README.txt	2010-07-29 15:55:11 UTC (rev 115214)
@@ -11,7 +11,7 @@
 * make so that resource references are automatically inserted in the
   HTML header.
 
-This library fulfills these conditions for a Zope 3/Grok setup.
+This library fulfills these conditions for a Zope Toolkit/Grok setup.
 
 We'll run through a few tests to demonstrate it. Note that the real
 code being tested is not in this document itself, but in the views described

Modified: hurry.zoperesource/trunk/src/hurry/zoperesource/configure.zcml
===================================================================
--- hurry.zoperesource/trunk/src/hurry/zoperesource/configure.zcml	2010-07-29 14:35:40 UTC (rev 115213)
+++ hurry.zoperesource/trunk/src/hurry/zoperesource/configure.zcml	2010-07-29 15:55:11 UTC (rev 115214)
@@ -1,11 +1,16 @@
 <configure
   xmlns="http://namespaces.zope.org/zope"
-  xmlns:grok="http://namespaces.zope.org/grok">
+  xmlns:grok="http://namespaces.zope.org/grok"
+  xmlns:hzr="http://namespaces.zope.org/hzr">
 
   <include package="z3c.autoinclude" file="meta.zcml" />
 
   <includeDependencies package="." />
 
+  <include package="hurry.zoperesource" file="meta.zcml" />
+
+  <hzr:setupHurryZopeResource />
+
   <grok:grok package="."/>
 
   <utility

Added: hurry.zoperesource/trunk/src/hurry/zoperesource/meta.zcml
===================================================================
--- hurry.zoperesource/trunk/src/hurry/zoperesource/meta.zcml	                        (rev 0)
+++ hurry.zoperesource/trunk/src/hurry/zoperesource/meta.zcml	2010-07-29 15:55:11 UTC (rev 115214)
@@ -0,0 +1,11 @@
+<configure xmlns:meta="http://namespaces.zope.org/meta">
+  <meta:directives namespace="http://namespaces.zope.org/hzr">
+ 
+    <meta:directive
+       name="setupHurryZopeResource"
+       schema=".zcml.ISetupHurryZopeResource"
+       handler=".zcml.action_setup" />
+
+  </meta:directives>
+
+</configure>

Modified: hurry.zoperesource/trunk/src/hurry/zoperesource/tests/view.py
===================================================================
--- hurry.zoperesource/trunk/src/hurry/zoperesource/tests/view.py	2010-07-29 14:35:40 UTC (rev 115213)
+++ hurry.zoperesource/trunk/src/hurry/zoperesource/tests/view.py	2010-07-29 15:55:11 UTC (rev 115214)
@@ -1,7 +1,7 @@
 from hurry.resource import Library, ResourceInclusion, bottom
 
 
-foo = Library("foo")
+foo = Library("foo", "foo_dir")
 
 a = ResourceInclusion(foo, "a.js")
 

Added: hurry.zoperesource/trunk/src/hurry/zoperesource/zcml.py
===================================================================
--- hurry.zoperesource/trunk/src/hurry/zoperesource/zcml.py	                        (rev 0)
+++ hurry.zoperesource/trunk/src/hurry/zoperesource/zcml.py	2010-07-29 15:55:11 UTC (rev 115214)
@@ -0,0 +1,34 @@
+from zope.interface import Interface
+from hurry import resource
+from hurry.resource import zca
+from zope import component
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
+from zope.browserresource.directory import DirectoryResourceFactory
+from zope.security.checker import NamesChecker
+
+class ISetupHurryZopeResource(Interface):
+    pass
+
+allowed_resource_names = (
+    'GET', 'HEAD', 'publishTraverse', 'browserDefault', 'request', '__call__')
+
+allowed_resourcedir_names = allowed_resource_names + ('__getitem__', 'get')
+
+def action_setup(_context):
+    """Publish all hurry.resource library entry points as resources.
+    """
+    resource.register_plugin(zca.Plugin())
+    
+    for library in resource.libraries():
+        checker = NamesChecker(allowed_resourcedir_names)
+        resource_factory = DirectoryResourceFactory(
+            library.path, checker, library.name)
+        
+        adapts = (IDefaultBrowserLayer,)
+        provides = Interface
+        
+        _context.action(
+            discriminator = ('adapter', adapts, provides, library.name),
+            callable = component.provideAdapter,
+            args = (resource_factory, adapts, provides, library.name))
+



More information about the checkins mailing list