[Grok-dev] About the grok.name() annotation
Darryl Cousins
darryl at darrylcousins.net.nz
Fri Jul 13 16:21:20 EDT 2007
Hi,
On Fri, 2007-07-13 at 20:53 +0200, Sebastian Ware wrote:
> My two pennies...
>
> I got the grok.name('view_name') concept quite fast. I am not saying
> I think calling it "name" was exceptionally perfect, but I use it and
> it wasn't too difficult for me to understand the idea that grok.name
> = "what I call it in the URL". It would have been easier if perhaps
> it would have been called grok.url_name().
grok.name is also used in other grokkers (e.g. AdapterGrokker) and
refers the the name by which an component is looked up. I've also reused
grok.name for grokkers of my own making following the convention of
naming the looking up. Without this convention the grok namespace would
become bloated with:
grok.url_name
grok.adapter_name
grok.catalog_name
etc, etc
Best regards,
Darryl
>
> I also got the part that not having a grok.name defaults it to the
> class name in lower letters.
>
> Mvh Sebastian
>
> 13 jul 2007 kl. 19.31 skrev Luciano Ramalho:
>
> > A good way to evaluate an API is trying to explain it...
> >
> > While reviewing the tutorial, I think we need another annotation use
> > instad of grok.name() in the most common use case: defining default
> > views.
> >
> > As far as I can see (not too far, I admit) all other uses of
> > grok.name() are pretty rare.
> >
> > What is it that the grok.name() declaration really names? From the
> > tutorial:
> >
> > class EntryIndex(grok.View):
> > grok.context(Entry)
> > grok.name('index')
> >
> > After this code runs, what is it that is now called "index"? (again,
> > from the perspective of the Grok user who does not know Zope 3!) It's
> > not "the view". When I read the code above I see that the view is
> > called EntryIndex. It's not the template either: that is called
> > entryindex.pt. What has been named "index" here is something that is
> > totally abstract from the Grok perspective. The origin of that
> > declaration is the browser.page ZCML directive, but that is no
> > explanation to a newbie. And if by far the most common reason to use
> > grok.name is to call the view "index", then it would be better to have
> > an annotation for that purpose, let's say: default_view:
> >
> > class EntryIndex(grok.View):
> > grok.context(Entry)
> > grok.default_view()
> >
> >
> > [ ]s
> > Luciano
> > _______________________________________________
> > Grok-dev mailing list
> > Grok-dev at zope.org
> > http://mail.zope.org/mailman/listinfo/grok-dev
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev
More information about the Grok-dev
mailing list