[Checkins] SVN: grok/trunk/s Add support for grokcore.layout.
Sylvain Viollon
sylvain at infrae.com
Wed Jul 13 14:51:36 EDT 2011
Log message for revision 122201:
Add support for grokcore.layout.
Changed:
U grok/trunk/setup.py
U grok/trunk/src/grok/__init__.py
U grok/trunk/src/grok/components.py
U grok/trunk/src/grok/configure.zcml
U grok/trunk/src/grok/interfaces.py
-=-
Modified: grok/trunk/setup.py
===================================================================
--- grok/trunk/setup.py 2011-07-13 18:41:34 UTC (rev 122200)
+++ grok/trunk/setup.py 2011-07-13 18:51:36 UTC (rev 122201)
@@ -46,6 +46,7 @@
'grokcore.content',
'grokcore.formlib >= 1.4',
'grokcore.json',
+ 'grokcore.layout',
'grokcore.message',
'grokcore.rest',
'grokcore.security >= 1.1',
Modified: grok/trunk/src/grok/__init__.py
===================================================================
--- grok/trunk/src/grok/__init__.py 2011-07-13 18:41:34 UTC (rev 122200)
+++ grok/trunk/src/grok/__init__.py 2011-07-13 18:51:36 UTC (rev 122201)
@@ -56,6 +56,10 @@
from grokcore.formlib import AutoFields
from grokcore.formlib import Fields
+from grokcore.layout import UnauthorizedPage
+from grokcore.layout import NotFoundPage
+from grokcore.layout import ExceptionPage
+
from grokcore.annotation import Annotation
from grokcore.site.interfaces import IApplication
@@ -90,6 +94,8 @@
from grok.components import Application
from grok.components import View, Form, AddForm, EditForm, DisplayForm
+from grok.components import Layout, Page, FormPage
+from grok.components import AddFormPage, EditFormPage, DisplayFormPage
from grok.components import ExceptionView, NotFoundView, UnauthorizedView
from grok.components import XMLRPC, REST, JSON
from grok.components import Indexes
Modified: grok/trunk/src/grok/components.py
===================================================================
--- grok/trunk/src/grok/components.py 2011-07-13 18:41:34 UTC (rev 122200)
+++ grok/trunk/src/grok/components.py 2011-07-13 18:51:36 UTC (rev 122201)
@@ -42,6 +42,7 @@
import grokcore.view
import grokcore.site
import grokcore.message
+import grokcore.layout
from grok import interfaces, util
# BBB this is for import backward compatibility.
@@ -66,7 +67,21 @@
interface.implements(grokcore.site.interfaces.IApplication)
-class View(grokcore.view.View):
+class ViewSupportMixin(object):
+
+ def application_url(self, name=None, data=None):
+ """Return the URL of the closest :class:`grok.Application` object in
+ the hierarchy or the URL of a named object (``name``
+ parameter) relative to the closest application object.
+ """
+ return util.application_url(self.request, self.context, name, data)
+
+ def flash(self, message, type='message'):
+ """Send a short message to the user."""
+ grokcore.message.send(message, type=type, name='session')
+
+
+class View(ViewSupportMixin, grokcore.view.View):
"""The base class for views with templates in Grok applications.
Implements the :class:`grokcore.view.interfaces.IGrokView`
@@ -232,7 +247,7 @@
render.base_method = True
-class Form(grokcore.formlib.Form, View):
+class Form(ViewSupportMixin, grokcore.formlib.Form):
"""The base class for forms in Grok applications.
A class that inherits from :class:`grok.Form` is a
@@ -249,27 +264,40 @@
interface.implements(interfaces.IGrokForm)
-class AddForm(grokcore.formlib.AddForm, View):
+class AddForm(ViewSupportMixin, grokcore.formlib.AddForm):
"""Base class for add forms in Grok applications."""
interface.implements(interfaces.IGrokForm)
-class DisplayForm(grokcore.formlib.DisplayForm, View):
+class DisplayForm(ViewSupportMixin, grokcore.formlib.DisplayForm):
"""Base class for display forms in Grok applications."""
interface.implements(interfaces.IGrokForm)
-class EditForm(grokcore.formlib.EditForm, View):
+class EditForm(ViewSupportMixin, grokcore.formlib.EditForm):
"""Base class for edit forms in Grok applications."""
interface.implements(interfaces.IGrokForm)
-class ViewishViewSupport(grokcore.view.ViewSupport):
+class Layout(ViewSupportMixin, grokcore.layout.Layout):
+ pass
- def application_url(self, name=None, data=None):
- return util.application_url(self.request, self.context, name, data)
+class Page(ViewSupportMixin, grokcore.layout.Page):
+ pass
+class FormPage(ViewSupportMixin, grokcore.layout.FormPage):
+ pass
+class AddFormPage(ViewSupportMixin, grokcore.layout.AddFormPage):
+ pass
+
+class EditFormPage(ViewSupportMixin, grokcore.layout.EditFormPage):
+ pass
+
+class DisplayFormPage(ViewSupportMixin, grokcore.layout.DisplayFormPage):
+ pass
+
+
class IndexesClass(object):
"""Base class for index collections in a Grok application.
Modified: grok/trunk/src/grok/configure.zcml
===================================================================
--- grok/trunk/src/grok/configure.zcml 2011-07-13 18:41:34 UTC (rev 122200)
+++ grok/trunk/src/grok/configure.zcml 2011-07-13 18:51:36 UTC (rev 122201)
@@ -1,3 +1,4 @@
+
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
@@ -40,6 +41,7 @@
<include package="grokcore.annotation" />
<include package="grokcore.formlib" />
<include package="grokcore.json" />
+ <include package="grokcore.layout" />
<include package="grokcore.site" />
<include package="grokcore.traverser" />
<include package="grokcore.view" />
Modified: grok/trunk/src/grok/interfaces.py
===================================================================
--- grok/trunk/src/grok/interfaces.py 2011-07-13 18:41:34 UTC (rev 122200)
+++ grok/trunk/src/grok/interfaces.py 2011-07-13 18:51:36 UTC (rev 122201)
@@ -23,6 +23,7 @@
import grokcore.annotation.interfaces
import grokcore.component.interfaces
import grokcore.formlib.interfaces
+import grokcore.layout.interfaces
import grokcore.json.interfaces
import grokcore.security.interfaces
import grokcore.rest.interfaces
@@ -44,6 +45,7 @@
grokcore.site.interfaces.IBaseClasses,
grokcore.view.interfaces.IBaseClasses,
grokcore.json.interfaces.IBaseClasses,
+ grokcore.layout.interfaces.IBaseClasses,
grokcore.traverser.interfaces.IBaseClasses,
grokcore.xmlrpc.interfaces.IBaseClasses):
Model = interface.Attribute(
@@ -114,6 +116,7 @@
class IGrokAPI(grokcore.formlib.interfaces.IGrokcoreFormlibAPI,
+ grokcore.layout.interfaces.IGrokcoreLayoutAPI,
grokcore.security.interfaces.IGrokcoreSecurityAPI,
grokcore.site.interfaces.IGrokcoreSiteAPI,
grokcore.view.interfaces.IGrokcoreViewAPI,
More information about the checkins
mailing list