[Grok-dev] Re: 0.14 todo list
Sylvain Viollon
sylvain at infrae.com
Thu Jul 31 04:48:44 EDT 2008
On Thu, 31 Jul 2008 10:35:34 +0200
Sylvain Viollon <sylvain at infrae.com> wrote:
> On Wed, 30 Jul 2008 23:14:40 +0100
> Martin Aspeli <optilude at gmx.net> wrote:
>
> >
> > Mmmm.... is there any documentation on how to use this in plain Zope
> > 2 (or Plone)? I'm getting confused by Silva stuff. ;-)
> >
>
> Not, really, but that's easy. In a meta.zcml somewhere, add an:
>
> <include package="five.grok" file="meta.zcml" />
> <include package="five.grok" />
>
> In the package where your view is, add to the configure.zcml:
>
> <grok:grok package=".wheremyviewis" />
>
> And your view will be something like:
>
> import five.grok
>
> class MyView(five.grok.View):
>
> five.grok.context(IMyContent)
> five.grok.name(u"test.html")
>
> def render(self):
> return u"Hello World"
>
>
> That's it. After you have the same rules than in Grok for templates,
> and so on.
>
> Forms are more complex, since you need to build a mixin with Five:
>
> from grokcore.formlib.components import GrokForm
> from grokcore.formlib import action
>
I forgot:
from Products.Five.formlib import formbase
> class PageForm(GrokForm, formbase.PageForm, five.grok.View):
>
> five.grok.context(IMyContent)
> five.grok.name(u"edit.html")
>
> @action(u"Test me")
> def action_test(self, **data):
> self.status = "Tested"
>
>
> Don't forget to include in the configure.zcml grokcore.formlib.
> Security can be done with grokcore.security.require ...
>
> Voila.
>
> Sylvain,
>
>
--
Sylvain Viollon -- Infrae
t +31 10 243 7051 -- http://infrae.com
Hoevestraat 10 3033GC Rotterdam -- The Netherlands
More information about the Grok-dev
mailing list