[Grok-dev] Re: five.grok
sylvain at infrae.com
Fri Aug 1 04:39:41 EDT 2008
On Thu, 31 Jul 2008 21:59:12 +0100
Martin Aspeli <optilude at gmx.net> wrote:
> Hi Sylvain,
> >> Would it work to use the context() and name() directives from
> >> grokcore.view instead of five.grok?
> > Yes, they are just imported in five.grok, if I remember correctly.
> > It's just that's better to have one import instead of two.
> Except that it makes existing documentation/examples that use
> grokcore.view seem to not apply when in fact they do.
Well, you have to change an import. The common fact is that in grok,
you don't import things from grokcore.component, or grokcore.views and
so on, you just import things from grok:
So in Zope 2, your import will be:
from five import grok
Grokcore packages are just parts of grok implementation, which can be
used in other context than grok itself, like to build grok in Zope 2.
So I think documentation are preserved, you just have your first import
which is different.
But recently a lot of work have been done on grokcore packages, and
not everything from grokcore packages are imported in five.grok like
in grok, I think.
> > I think in grok documentation.
> I did look for a canonical "how templates and views and forms work"
> document, but found only the general tutorial. I may've missed
> something, though.
I never look at the grok documentation, but you don't have anything
new if you compare to the Zope 3 way of doing things. That's just you
don't have to register explicitly everything.
> > The rule is unless you used the
> > templatedir directive in module to configure a different template
> > directory, if a view don't define a render method, a template named
> > with the name of your view class in lower case is search in a
> > directory which have the same name than your python module (in
> > lower case as well I think).
> Cool. I can't wait to try this out. :)
> > So if your view is in wheremyviewis.py, the template
> > wheremyviewis/myview.pt is going to be used if you remove the render
> > method above.
> And what about the template directory stuff? Is that explicit, or
> does viewname_templates work always?
Yes, it's wheremyviewis_templates/myview.pt, not the first I gave (I
forgot the _templates), unless you specified an another directory with
grokcore.view.templatedir in your module.
> > Basically, we have to build a grokker which create the form_fields
> > attribute like for formlib, wrap actions ... We will have to
> > register the form to the ZCA as view wrapped with the form_wrapper
> > provided in plone.z3cform.
> Right. Please let's talk about this. I need this exact same thing for
> Dexterity, with support for add and edit forms (as well as standalone
> form views, but that's not really specific to Dexterity). I think
> plone.z3cform would be a natural place to keep the grokking code.
If you add the grokking code to plone.z3cform, this going to mean
that's everybody who want to use z3c.form in Zope 2 will have to either
use Grok, or if they don't work, rebuild their own support. I will
prefer to have a five.grok.z3cform, which depends on plone.z3cform.
I may have some time to work on that today, or at the beginning of
Sylvain Viollon -- Infrae
t +31 10 243 7051 -- http://infrae.com
Hoevestraat 10 3033GC Rotterdam -- The Netherlands
More information about the Grok-dev