[Grok-dev] five.grok (was: 0.14 todo list)

Martin Aspeli optilude at gmx.net
Thu Jul 31 04:47:12 EDT 2008


Hi Sylvain,

>> 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:

Excellent!

>   <include package="five.grok" file="meta.zcml" />
>   <include package="five.grok" />

What's the relationship between five.grok and grokcore.view? Is the 
latter a dependency on the former?

> 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")

Would it work to use the context() and name() directives from 
grokcore.view instead of five.grok?

>       def render(self):
>           return u"Hello World"
> 
> 
> That's it. After you have the same rules than in Grok for templates,
> and so on.

Are these documented anywhere?

> 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.

Cool! I'm more interested in a z3c.form version, though. Is anyone 
working on that? If not, I would be interested to figure out how to do that.

> Security can be done with grokcore.security.require ...

Cool! Does that take IPermission utility names? Or Zope 2 permission 
strings?

Thanks again!

Martin

-- 
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book



More information about the Grok-dev mailing list