[Checkins] SVN: five.grok/trunk/src/five/grok/ We still need the ZopeTwo version of directory resources, since Zope 2 and Zope 3 resources are different

Martin Aspeli optilude at gmx.net
Sun Nov 15 20:26:57 EST 2009


Log message for revision 105664:
  We still need the ZopeTwo version of directory resources, since Zope 2 and Zope 3 resources are different

Changed:
  U   five.grok/trunk/src/five/grok/__init__.py
  U   five.grok/trunk/src/five/grok/components.py
  U   five.grok/trunk/src/five/grok/meta.py
  U   five.grok/trunk/src/five/grok/meta.zcml

-=-
Modified: five.grok/trunk/src/five/grok/__init__.py
===================================================================
--- five.grok/trunk/src/five/grok/__init__.py	2009-11-15 20:29:31 UTC (rev 105663)
+++ five.grok/trunk/src/five/grok/__init__.py	2009-11-16 01:26:56 UTC (rev 105664)
@@ -23,7 +23,7 @@
 from five.grok.components import Model, Container, Site, LocalUtility
 from five.grok.components import Form, AddForm
 from five.grok.components import EditForm, DisplayForm
-from five.grok.components import ViewletManager
+from five.grok.components import View, ViewletManager
 from five.grok.formlib import AutoFields
 
 # backwards compatibility. Probably not needed by many, but just in case.
@@ -35,7 +35,7 @@
 from five.grok.components import ZopeTwoPageTemplateFile as PageTemplateFile
 
 # Override DirectoryResource to use Zope 2 one
-#from five.grok.components import ZopeTwoDirectoryResource as DirectoryResource
+from five.grok.components import ZopeTwoDirectoryResource as DirectoryResource
 
 # Only export public API
 from five.grok.interfaces import IFiveGrokAPI

Modified: five.grok/trunk/src/five/grok/components.py
===================================================================
--- five.grok/trunk/src/five/grok/components.py	2009-11-15 20:29:31 UTC (rev 105663)
+++ five.grok/trunk/src/five/grok/components.py	2009-11-16 01:26:56 UTC (rev 105664)
@@ -76,6 +76,11 @@
 class View(grokcore.view.View):
     martian.baseclass()
 
+    def __init__(self, context, request):
+        super(View, self).__init__(context, request)
+        if self.static is not None:
+            # Set parent so that we have an acquisition chain
+            self.static.__parent__ = context
 
 class ViewAwareZopePageTemplate(ZopePageTemplate):
 

Modified: five.grok/trunk/src/five/grok/meta.py
===================================================================
--- five.grok/trunk/src/five/grok/meta.py	2009-11-15 20:29:31 UTC (rev 105663)
+++ five.grok/trunk/src/five/grok/meta.py	2009-11-16 01:26:56 UTC (rev 105664)
@@ -84,41 +84,41 @@
     return True
 
 
-# class DirectoryResourceGrokker(martian.ClassGrokker):
-#     martian.component(components.ZopeTwoDirectoryResource)
+class DirectoryResourceGrokker(martian.ClassGrokker):
+    martian.component(components.ZopeTwoDirectoryResource)
 
-#     martian.directive(grokcore.view.name, default=None)
-#     martian.directive(grokcore.view.path)
-#     martian.directive(grokcore.view.layer, default=IDefaultBrowserLayer)
+    martian.directive(grokcore.view.name, default=None)
+    martian.directive(grokcore.view.path)
+    martian.directive(grokcore.view.layer, default=IDefaultBrowserLayer)
 
-#     def grok(self, name, factory, module_info, **kw):
-#         # Need to store the module info object on the directory resource
-#         # class so that it can look up the actual directory.
-#         factory.module_info = module_info
-#         return super(DirectoryResourceGrokker, self).grok(
-#             name, factory, module_info, **kw)
+    def grok(self, name, factory, module_info, **kw):
+        # Need to store the module info object on the directory resource
+        # class so that it can look up the actual directory.
+        factory.module_info = module_info
+        return super(DirectoryResourceGrokker, self).grok(
+            name, factory, module_info, **kw)
 
-#     def execute(self, factory, config, name, path, layer, **kw):
-#         resource_path = _get_resource_path(factory.module_info, path)
-#         name = name or factory.module_info.dotted_name
-#         return _register_resource(config, resource_path, name, layer)
+    def execute(self, factory, config, name, path, layer, **kw):
+        resource_path = _get_resource_path(factory.module_info, path)
+        name = name or factory.module_info.dotted_name
+        return _register_resource(config, resource_path, name, layer)
 
 
-# class StaticResourcesGrokker(martian.GlobalGrokker):
+class StaticResourcesGrokker(martian.GlobalGrokker):
 
-#     def grok(self, name, module, module_info, config, **kw):
-#         # we're only interested in static resources if this module
-#         # happens to be a package
-#         if not module_info.isPackage():
-#             return False
-#         resource_path = _get_resource_path(module_info, 'static')
+    def grok(self, name, module, module_info, config, **kw):
+        # we're only interested in static resources if this module
+        # happens to be a package
+        if not module_info.isPackage():
+            return False
+        resource_path = _get_resource_path(module_info, 'static')
 
-#         if not os.path.exists(resource_path):
-#             return False
+        if not os.path.exists(resource_path):
+            return False
 
-#         name = module_info.dotted_name
-#         layer = IDefaultBrowserLayer
-#         return _register_resource(config, resource_path, name, layer)
+        name = module_info.dotted_name
+        layer = IDefaultBrowserLayer
+        return _register_resource(config, resource_path, name, layer)
 
 
 class ViewletSecurityGrokker(martian.ClassGrokker):

Modified: five.grok/trunk/src/five/grok/meta.zcml
===================================================================
--- five.grok/trunk/src/five/grok/meta.zcml	2009-11-15 20:29:31 UTC (rev 105663)
+++ five.grok/trunk/src/five/grok/meta.zcml	2009-11-16 01:26:56 UTC (rev 105664)
@@ -9,7 +9,7 @@
   <include package="grokcore.site" file="meta.zcml" />
 
   <!-- Load minimal support of grokcore.view, views + templates  -->
-  <include package="grokcore.view" file="meta.zcml" />
+  <include package="grokcore.view" file="meta-minimal.zcml" />
   <include package="grokcore.viewlet" file="meta.zcml" />
   <include package="grokcore.formlib" file="meta.zcml" />
 



More information about the checkins mailing list