[Grok-dev] Question about viewlets

Kevin Smith kevin at mcweekly.com
Thu May 1 17:05:46 EDT 2008


First I think it's awesome that viewlets have made it to the grok 
mainstream, but I do have a question about
the implementation.

class Fred(grok.Viewlet):
    grok.viewletmanager(CountersManager)
    grok.context(GrokExample)
    grok.template('fred_template')
    grok.order(2)

    def update(self):
        self.context.fred.count += 1
        self.counter = self.context.fred.count

Since grok.viewletmanager and grok.context are are integral to the 
registration of a viewlet, I can see why they are directives.
However, since grok.order is not integral to the registration of a 
viewlet,  should it really be a directive? Assuming that someone is
using the default viewletmanager ordering scheme, wouldn't a simple 
attribute suffice?

IOW since grok.viewletmanager and grok.context *cannot* be expressed as 
a simple attributes, they *must* be grok directives, and
since grok.order can be expressed as a simple attribute it must not be a 
grok.directive.

I mention this since it seems to fit into the recent "what is grok/what 
is not grok" discussion.

Kevin Smith




More information about the Grok-dev mailing list