[Grok-dev] Re: 0.14 todo list

Jean-François Roche jfroche at affinitic.be
Thu Jul 31 05:07:28 EDT 2008


It would be great if you could show the Forms & Formlib mixin inside the
README.txt we have in
http://svn.zope.org/five.grok/trunk/src/five/grok/README.txt?rev=88533&view=markup

To avoid having a doctest within a python file (the README.txt is
supposed to also explain registration) as most grok doctest are, we have
a little change in the grok notation inside this doctest:

   >>>
are doctest

   <<<
are setup of grok (executed first).

See you,

			Jeff


Sylvain Viollon 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
> 
>    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,
> 
> 




More information about the Grok-dev mailing list