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

Martijn Faassen faassen at startifact.com
Thu Jul 19 04:35:56 EDT 2007

Hi there,

Luciano Ramalho wrote:

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

Having a grok.default_view() that is equivalent to grok.name('index') 
sounds like a good idea.

grok.name() itself is still useful, however, as it affects the view 
name. Note that even with grok.name('index') the view will become 
available as /index (as well as being the default).



More information about the Grok-dev mailing list