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

Luciano Ramalho luciano at ramalho.org
Fri Jul 13 13:31:10 EDT 2007


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


More information about the Grok-dev mailing list