[Grok-dev] About the grok.name() annotation

Sebastian Ware sebastian at urbantalk.se
Fri Jul 13 14:53:51 EDT 2007


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

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



More information about the Grok-dev mailing list