[Checkins] SVN: five.grok/trunk/ Merge sylvain-viewlets branch. Update README and HISTORY.

Sylvain Viollon sylvain at infrae.com
Sat Nov 15 08:44:28 EST 2008


Log message for revision 92961:
  Merge sylvain-viewlets branch. Update README and HISTORY.
  
  

Changed:
  U   five.grok/trunk/README.txt
  U   five.grok/trunk/docs/HISTORY.txt
  U   five.grok/trunk/five.grok-configure.zcml
  U   five.grok/trunk/setup.py
  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/configure.zcml
  U   five.grok/trunk/src/five/grok/ftesting.zcml
  U   five.grok/trunk/src/five/grok/ftests/test_grok_functional.py
  A   five.grok/trunk/src/five/grok/ftests/viewlet/
  U   five.grok/trunk/src/five/grok/meta.py
  U   five.grok/trunk/src/five/grok/meta.zcml
  U   five.grok/trunk/src/five/grok/templatereg.py
  U   five.grok/trunk/src/five/grok/testing.py

-=-
Modified: five.grok/trunk/README.txt
===================================================================
--- five.grok/trunk/README.txt	2008-11-15 13:20:53 UTC (rev 92960)
+++ five.grok/trunk/README.txt	2008-11-15 13:44:27 UTC (rev 92961)
@@ -6,15 +6,15 @@
 Introduction
 ------------
 
-`five.grok` is a development layer for Zope 2, based on Grok framework concepts.
+`five.grok` is a development layer for Zope 2, based on Grok framework
+concepts.
 
-The development techniques are similar to the ones used with Grok framework. 
+The development techniques are similar to the ones used with Grok
+framework.
 
 It is based on `grokcore` namespace packages that were factored out of Grok
 framework.
 
-
-
 Implemented features
 --------------------
 
@@ -25,8 +25,10 @@
 
 - Permissions,
 
-- Views,
+- Views and Viewlets,
 
+- Skins and resources directories,
+
 - Page Templates (using the Zope 2 Page Templates),
 
 - Formlib forms.
@@ -40,7 +42,25 @@
 
   import grok
 
+Installation
+------------
 
+After adding the dependency to ``five.grok`` in your project, you have
+to load the following ZCML::
+
+  <include package="five.grok" />
+
+Note
+~~~~
+
+``five.grok`` have some dependencies on Zope 3 eggs. With Zope 2, you
+can fake those dependencies in buildout by using the option
+``fake-zope-eggs = true`` of ``plone.recipe.zope2instance``. However,
+``five.grok`` requires ``zope.component`` 3.4 at least. You can
+exclude that egg by mentioning ``zope.component`` in the option
+``skip-fake-eggs`` in the same buildout section.
+
+
 More information
 ----------------
 

Modified: five.grok/trunk/docs/HISTORY.txt
===================================================================
--- five.grok/trunk/docs/HISTORY.txt	2008-11-15 13:20:53 UTC (rev 92960)
+++ five.grok/trunk/docs/HISTORY.txt	2008-11-15 13:44:27 UTC (rev 92961)
@@ -4,12 +4,13 @@
 five.grok - 1.0a2 (Unreleased)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-* ...
+* Added support for viewlets with `grokcore.viewlet`_.
+  [thefunny42]
 
-five.grok - 1.0a1 (2008/10/22)
+five.grok - 1.0a1 (2008-10-22)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-* Added support for formlib forms with grokcore.formlib.
+* Added support for formlib forms with `grokcore.formlib`_.
   [thefunny42]
 
 * Added support for static resource directory.
@@ -34,3 +35,6 @@
   views).
   [regebro, gotcha]
 
+
+.. _grokcore.viewlet: http://pypi.python.org/pypi/grokcore.viewlet
+.. _grokcore.formlib: http://pypi.python.org/pypi/grokcore.formlib

Modified: five.grok/trunk/five.grok-configure.zcml
===================================================================
--- five.grok/trunk/five.grok-configure.zcml	2008-11-15 13:20:53 UTC (rev 92960)
+++ five.grok/trunk/five.grok-configure.zcml	2008-11-15 13:44:27 UTC (rev 92961)
@@ -1 +1 @@
-<include package="grokkers" />
\ No newline at end of file
+<include package="five.grok" />

Modified: five.grok/trunk/setup.py
===================================================================
--- five.grok/trunk/setup.py	2008-11-15 13:20:53 UTC (rev 92960)
+++ five.grok/trunk/setup.py	2008-11-15 13:44:27 UTC (rev 92961)
@@ -30,8 +30,9 @@
         'setuptools',
         'martian',
         'grokcore.component',
+        'grokcore.formlib',
+        'grokcore.view >= 1.1',
+        'grokcore.viewlet',
         'grokcore.security',
-        'grokcore.view >= 1.1',
-        'grokcore.formlib',
         ],
       )

Modified: five.grok/trunk/src/five/grok/__init__.py
===================================================================
--- five.grok/trunk/src/five/grok/__init__.py	2008-11-15 13:20:53 UTC (rev 92960)
+++ five.grok/trunk/src/five/grok/__init__.py	2008-11-15 13:44:27 UTC (rev 92961)
@@ -1,9 +1,26 @@
+#############################################################################
+#
+# Copyright (c) 2008 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
 from grokcore.component import *
 from grokcore.security import *
 from grokcore.view import *
+from grokcore.viewlet import *
 from grokcore.formlib import *
 
-from five.grok.components import View, Model, Form, AddForm, EditForm, DisplayForm
+from five.grok.components import View, Model, Form, AddForm
+from five.grok.components import EditForm, DisplayForm
+from five.grok.components import ViewletManager, Viewlet
 
 # Override the one from grokcore.view so that we get Zope 2 semantics
 from five.grok.components import ZopeTwoPageTemplate as PageTemplate

Modified: five.grok/trunk/src/five/grok/components.py
===================================================================
--- five.grok/trunk/src/five/grok/components.py	2008-11-15 13:20:53 UTC (rev 92960)
+++ five.grok/trunk/src/five/grok/components.py	2008-11-15 13:44:27 UTC (rev 92961)
@@ -1,6 +1,22 @@
+#############################################################################
+#
+# Copyright (c) 2008 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
 import martian
 
 from zope.annotation.interfaces import IAttributeAnnotatable
+from zope.viewlet.interfaces import IViewletManager, IViewlet
+from zope.security.interfaces import IPermission
 from zope.app.pagetemplate.viewpagetemplatefile import ViewMapper
 from zope import interface, component
 
@@ -8,16 +24,23 @@
 from grokcore.formlib.components import GrokForm as BaseGrokForm
 from grokcore.formlib.components import default_display_template, default_form_template
 from grokcore.view.components import PageTemplate
+from grokcore.viewlet.components import Viewlet as BaseViewlet
+from grokcore.viewlet.components import ViewletManager as BaseViewletManager
 import grokcore.view
+import grokcore.security
 
 from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile \
     as BaseViewPageTemplateFile
 from Products.Five.browser.pagetemplatefile import getEngine
 from Products.Five.browser import resource
 from Products.Five.formlib import formbase
+from Products.Five.viewlet.manager import ViewletManagerBase as \
+    ZopeTwoBaseViewletManager
 from Products.PageTemplates.Expressions import SecureModuleImporter
 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
 from OFS.SimpleItem import SimpleItem
+
+from AccessControl import getSecurityManager
 import Acquisition
 
 
@@ -46,10 +69,10 @@
 # TODO: This should probably move to Products.Five.browser
 
 class ViewAwareZopePageTemplate(ZopePageTemplate):
-    
+
     def pt_getEngine(self):
         return getEngine()
-    
+
     def pt_getContext(self):
         try:
             root = self.getPhysicalRoot()
@@ -99,7 +122,7 @@
 
     def setFromFilename(self, filename, _prefix=None):
         self._template = ViewPageTemplateFile(filename, _prefix)
-    
+
     def render(self, view):
         namespace = self.getNamespace(view)
         template = self._template.__of__(view)
@@ -138,7 +161,7 @@
     def __init__(self, *args):
         super(GrokForm, self).__init__(*args)
         self.__name__ = self.__view_name__
-        # super seems not to work correctly since this is needed again. 
+        # super seems not to work correctly since this is needed again.
         self.static = component.queryAdapter(
             self.request, interface.Interface,
             name = self.module_info.package_dotted_name)
@@ -167,3 +190,42 @@
 
     martian.baseclass()
     template = default_display_template
+
+
+# Viewlet / Viewlet Manager
+
+
+class ViewletManager(BaseViewletManager, ZopeTwoBaseViewletManager):
+
+    martian.baseclass()
+
+    def __init__(self, context, request, view):
+        super(ViewletManager, self).__init__(context, request, view)
+        if not (self.static is None):
+            # XXX See View
+            self.static = self.static.__of__(self)
+
+    # XXX See View
+    getPhysicalPath = Acquisition.Acquired
+
+    def filter(self, viewlets):
+        # XXX Need Zope 2 filter
+        return ZopeTwoBaseViewletManager.filter(self, viewlets)
+
+    def __getitem__(self, key):
+        # XXX Need Zope 2 __getitem__
+        return ZopeTwoBaseViewletManager.__getitem__(self, key)
+
+
+class Viewlet(BaseViewlet, Acquisition.Explicit):
+
+    martian.baseclass()
+
+    def __init__(self, context, request, view, manager):
+        super(Viewlet, self).__init__(context, request, view, manager)
+        if not (self.static is None):
+            # XXX See View
+            self.static = self.static.__of__(self)
+
+    # XXX See View
+    getPhysicalPath = Acquisition.Acquired

Modified: five.grok/trunk/src/five/grok/configure.zcml
===================================================================
--- five.grok/trunk/src/five/grok/configure.zcml	2008-11-15 13:20:53 UTC (rev 92960)
+++ five.grok/trunk/src/five/grok/configure.zcml	2008-11-15 13:44:27 UTC (rev 92961)
@@ -5,6 +5,8 @@
     i18n_domain="five.grok">
 
   <include package="grokcore.view" />
+  <include package="grokcore.viewlet" />
+  <include package="grokcore.formlib" />
 
   <browser:defaultView
       for="grokcore.component.interfaces.IContext"
@@ -16,7 +18,7 @@
       title="View"
       zcml:condition="not-installed kss.core"
       />
-      
+
   <includeOverrides file="overrides.zcml" />
 
 </configure>

Modified: five.grok/trunk/src/five/grok/ftesting.zcml
===================================================================
--- five.grok/trunk/src/five/grok/ftesting.zcml	2008-11-15 13:20:53 UTC (rev 92960)
+++ five.grok/trunk/src/five/grok/ftesting.zcml	2008-11-15 13:44:27 UTC (rev 92961)
@@ -9,7 +9,7 @@
 
   <!-- And also grok all the ftests /-->
   <grok:grok package="five.grok.ftests" />
-  
+
   <include package="zope.app.basicskin" />
   <include package="zope.app.rotterdam" />
 

Modified: five.grok/trunk/src/five/grok/ftests/test_grok_functional.py
===================================================================
--- five.grok/trunk/src/five/grok/ftests/test_grok_functional.py	2008-11-15 13:20:53 UTC (rev 92960)
+++ five.grok/trunk/src/five/grok/ftests/test_grok_functional.py	2008-11-15 13:44:27 UTC (rev 92961)
@@ -58,7 +58,7 @@
 
 def test_suite():
     suite = unittest.TestSuite()
-    for name in ['view', 'form']:
+    for name in ['view', 'viewlet','form']:
         suite.addTest(suiteFromPackage(name))
     return suite
 

Modified: five.grok/trunk/src/five/grok/meta.py
===================================================================
--- five.grok/trunk/src/five/grok/meta.py	2008-11-15 13:20:53 UTC (rev 92960)
+++ five.grok/trunk/src/five/grok/meta.py	2008-11-15 13:44:27 UTC (rev 92961)
@@ -1,3 +1,16 @@
+#############################################################################
+#
+# Copyright (c) 2008 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
 
 import martian
 import five.grok
@@ -2,9 +15,14 @@
 import grokcore.security
+import grokcore.view
+import grokcore.component
 
 from zope import interface, component
+from zope.contentprovider.interfaces import IContentProvider
 from zope.publisher.interfaces.browser import IDefaultBrowserLayer
 from five.grok import components
 from martian.error import GrokError
 
-from Products.Five.security import protectClass
+from grokcore.view.meta.views import default_view_name
+
+from Products.Five.security import protectClass, protectName
 from Globals import InitializeClass as initializeClass
@@ -16,7 +34,7 @@
 class ViewSecurityGrokker(martian.ClassGrokker):
     martian.component(five.grok.View)
     martian.directive(grokcore.security.require, name='permission')
-    
+
     def execute(self, factory, config, permission, **kw):
         if permission is None:
             permission = 'zope.Public'
@@ -36,6 +54,7 @@
 
         return True
 
+
 class StaticResourcesGrokker(martian.GlobalGrokker):
 
     def grok(self, name, module, module_info, config, **kw):
@@ -73,4 +92,35 @@
                 )
             return True
 
-        return False
\ No newline at end of file
+        return False
+
+
+class ViewletSecurityGrokker(martian.ClassGrokker):
+    martian.component(five.grok.Viewlet)
+    martian.directive(grokcore.security.require, name='permission')
+
+    def execute(self, factory, config, permission, **kw):
+        if permission is None:
+            permission = 'zope.Public'
+
+        attributes = ['update', 'render',]
+        config.action(
+            discriminator = ('five:protectClass', factory),
+            callable = protectClass,
+            args = (factory, permission)
+            )
+        for attribute in attributes:
+            config.action(
+                discriminator = ('five:protectName', factory, attribute),
+                callable = protectName,
+                args = (factory, attribute, permission)
+                )
+
+        # Protect the class
+        config.action(
+            discriminator = ('five:initialize:class', factory),
+            callable = initializeClass,
+            args = (factory,)
+            )
+
+        return True

Modified: five.grok/trunk/src/five/grok/meta.zcml
===================================================================
--- five.grok/trunk/src/five/grok/meta.zcml	2008-11-15 13:20:53 UTC (rev 92960)
+++ five.grok/trunk/src/five/grok/meta.zcml	2008-11-15 13:44:27 UTC (rev 92961)
@@ -8,6 +8,7 @@
 
   <!-- Load minimal support of grokcore.view, views + templates  -->
   <include package="grokcore.view" file="meta-minimal.zcml" />
+  <include package="grokcore.viewlet" file="meta.zcml" />
   <include package="grokcore.formlib" file="meta.zcml" />
 
   <!-- Include skin support as well -->

Modified: five.grok/trunk/src/five/grok/templatereg.py
===================================================================
--- five.grok/trunk/src/five/grok/templatereg.py	2008-11-15 13:20:53 UTC (rev 92960)
+++ five.grok/trunk/src/five/grok/templatereg.py	2008-11-15 13:44:27 UTC (rev 92961)
@@ -1,3 +1,17 @@
+#############################################################################
+#
+# Copyright (c) 2008 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
 import grokcore.component
 from grokcore.view.interfaces import ITemplateFileFactory
 
@@ -8,4 +22,4 @@
     grokcore.component.name('pt')
 
     def __call__(self, filename, _prefix=None):
-        return ZopeTwoPageTemplate(filename=filename, _prefix=_prefix)
\ No newline at end of file
+        return ZopeTwoPageTemplate(filename=filename, _prefix=_prefix)

Modified: five.grok/trunk/src/five/grok/testing.py
===================================================================
--- five.grok/trunk/src/five/grok/testing.py	2008-11-15 13:20:53 UTC (rev 92960)
+++ five.grok/trunk/src/five/grok/testing.py	2008-11-15 13:44:27 UTC (rev 92961)
@@ -49,7 +49,7 @@
     result = zcml.the_multi_grokker.grok(name, component,
                                          module_info=module_info,
                                          config=config)
-    config.execute_actions()    
+    config.execute_actions()
     return result
 
 def warn(message, category=None, stacklevel=1):
@@ -121,5 +121,3 @@
 
 GrokFunctionalLayer = Layer
 
-
- 



More information about the Checkins mailing list