[Checkins] SVN: hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/zcml.py Register a hurry.resource aware directory resource factory for every resource library

Jan-Jaap Driessen jdriessen at thehealthagency.com
Mon Nov 15 11:46:04 EST 2010


Log message for revision 118413:
  Register a hurry.resource aware directory resource factory for every resource library

Changed:
  U   hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/zcml.py

-=-
Modified: hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/zcml.py
===================================================================
--- hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/zcml.py	2010-11-15 16:44:58 UTC (rev 118412)
+++ hurry.zoperesource/branches/janjaapdriessen-wsgi/src/hurry/zoperesource/zcml.py	2010-11-15 16:46:04 UTC (rev 118413)
@@ -1,29 +1,29 @@
 from zope.interface import Interface
 from zope import component
 from zope.publisher.interfaces.browser import IBrowserRequest
-from zope.browserresource.directory import DirectoryResourceFactory
 from zope.security.checker import NamesChecker
+
 from hurry import resource
 from hurry.zoperesource.zopesupport import Plugin
+from hurry.zoperesource.zopesupport import HurryDirectoryResourceFactory
 
-class ISetupHurryZopeResource(Interface):
-    pass
 
-allowed_resource_names = (
-    'GET', 'HEAD', 'publishTraverse', 'browserDefault', 'request', '__call__')
+def create_resource_factory(library):
+    allowed_resource_names = ('GET', 'HEAD', 'publishTraverse',
+                              'browserDefault', 'request', '__call__')
 
-allowed_resourcedir_names = allowed_resource_names + ('__getitem__', 'get')
+    allowed_resourcedir_names = allowed_resource_names + ('__getitem__', 'get')
 
+    checker = NamesChecker(allowed_resourcedir_names)
+    return HurryDirectoryResourceFactory(library.path, checker, library.name)
+
 def action_setup(_context):
     """Publish all hurry.resource library entry points as resources.
     """
     resource.register_plugin(Plugin())
 
     for library in resource.libraries():
-        checker = NamesChecker(allowed_resourcedir_names)
-        resource_factory = DirectoryResourceFactory(
-            library.path, checker, library.name)
-
+        resource_factory = create_resource_factory(library)
         adapts = (IBrowserRequest,)
         provides = Interface
 



More information about the checkins mailing list