[Checkins] SVN: grok/trunk/ Use IContext and introduce IContainer.
Make traversers work against
Martijn Faassen
faassen at infrae.com
Sat May 3 12:23:59 EDT 2008
Log message for revision 86253:
Use IContext and introduce IContainer. Make traversers work against
those, so that we can implement new content classes and get all the
Grok features.
Changed:
U grok/trunk/CHANGES.txt
U grok/trunk/src/grok/admin/objectinfo.txt
U grok/trunk/src/grok/components.py
U grok/trunk/src/grok/configure.zcml
U grok/trunk/src/grok/interfaces.py
-=-
Modified: grok/trunk/CHANGES.txt
===================================================================
--- grok/trunk/CHANGES.txt 2008-05-03 16:12:17 UTC (rev 86252)
+++ grok/trunk/CHANGES.txt 2008-05-03 16:23:59 UTC (rev 86253)
@@ -50,6 +50,16 @@
lookup if ``grok.context`` is not present). This relies on a feature
introduced in grokcore.component 1.1.
+* ``grok.Model`` implements ``grok.interfaces.IContext`` now (which is
+ imported from ``grokcore.component``). ``grok.Container`` now
+ implements ``grok.interfaces.IContainer``. Traversers and default
+ views have been set up for these interfaces, so that new
+ implementations that function as a model or container can be easily
+ created. Just use ``grok.implements(IContainer)`` or
+ ``grok.implements(IContext)``. This is useful for Grok extensions
+ that want to implement new content classes.
+
+
Bug fixes
---------
Modified: grok/trunk/src/grok/admin/objectinfo.txt
===================================================================
--- grok/trunk/src/grok/admin/objectinfo.txt 2008-05-03 16:12:17 UTC (rev 86252)
+++ grok/trunk/src/grok/admin/objectinfo.txt 2008-05-03 16:23:59 UTC (rev 86253)
@@ -337,7 +337,7 @@
(<InterfaceClass zope.app.folder.interfaces.IFolder>, <InterfaceClass persistent.interfaces.IPersistent>, <InterfaceClass zope.location.interfaces.IPossibleSite>, <InterfaceClass zope.app.container.interfaces.IContained>)
>>> sweethome_info.getProvidedInterfaces()
- (<InterfaceClass zope.annotation.interfaces.IAttributeAnnotatable>, <InterfaceClass zope.app.container.interfaces.IContainer>, <InterfaceClass zope.app.container.interfaces.IContained>, <InterfaceClass persistent.interfaces.IPersistent>, <InterfaceClass grokcore.component.interfaces.IContext>)
+ (<InterfaceClass zope.annotation.interfaces.IAttributeAnnotatable>, <InterfaceClass grok.interfaces.IContainer>, <InterfaceClass zope.app.container.interfaces.IContainer>, <InterfaceClass zope.app.container.interfaces.IContained>, <InterfaceClass persistent.interfaces.IPersistent>)
Manfred again, is a bit too plain to give us interesting information:
Modified: grok/trunk/src/grok/components.py
===================================================================
--- grok/trunk/src/grok/components.py 2008-05-03 16:12:17 UTC (rev 86252)
+++ grok/trunk/src/grok/components.py 2008-05-03 16:23:59 UTC (rev 86253)
@@ -59,15 +59,15 @@
from grok import interfaces, formlib, util
-class Model(Contained, persistent.Persistent, grokcore.component.Context):
+class Model(Contained, persistent.Persistent):
# XXX Inheritance order is important here. If we reverse this,
# then containers can't be models anymore because no unambigous MRO
# can be established.
- interface.implements(IAttributeAnnotatable)
+ interface.implements(IAttributeAnnotatable, interfaces.IContext)
-class Container(BTreeContainer, grokcore.component.Context):
- interface.implements(IAttributeAnnotatable)
+class Container(BTreeContainer):
+ interface.implements(IAttributeAnnotatable, interfaces.IContainer)
class OrderedContainer(Container):
@@ -464,8 +464,8 @@
pass
-class ModelTraverser(Traverser):
- component.adapts(Model, IHTTPRequest)
+class ContextTraverser(Traverser):
+ component.adapts(interfaces.IContext, IHTTPRequest)
def traverse(self, name):
traverse = getattr(self.context, 'traverse', None)
@@ -474,7 +474,7 @@
class ContainerTraverser(Traverser):
- component.adapts(Container, IHTTPRequest)
+ component.adapts(interfaces.IContainer, IHTTPRequest)
def traverse(self, name):
traverse = getattr(self.context, 'traverse', None)
Modified: grok/trunk/src/grok/configure.zcml
===================================================================
--- grok/trunk/src/grok/configure.zcml 2008-05-03 16:12:17 UTC (rev 86252)
+++ grok/trunk/src/grok/configure.zcml 2008-05-03 16:23:59 UTC (rev 86253)
@@ -30,7 +30,7 @@
<securityPolicy
component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
- <adapter factory=".components.ModelTraverser" />
+ <adapter factory=".components.ContextTraverser" />
<adapter factory=".components.ContainerTraverser" />
<browser:defaultView
Modified: grok/trunk/src/grok/interfaces.py
===================================================================
--- grok/trunk/src/grok/interfaces.py 2008-05-03 16:12:17 UTC (rev 86252)
+++ grok/trunk/src/grok/interfaces.py 2008-05-03 16:23:59 UTC (rev 86253)
@@ -18,6 +18,7 @@
from zope.formlib.interfaces import reConstraint
from zope.interface.interfaces import IInterface
from zope.viewlet.interfaces import IViewletManager as IViewletManagerBase
+from zope.app.container.interfaces import IContainer as IContainerBase
from grokcore.component.interfaces import IContext
@@ -499,6 +500,10 @@
def render(view):
"""Renders the template"""
+class IContainer(IContext, IContainerBase):
+ """A Grok container.
+ """
+
class IViewletManager(IViewletManagerBase):
"""The Grok viewlet manager.
"""
More information about the Checkins
mailing list