[Grok-dev] Re: Are functions starting with "handle_" considered
special?
Martijn Faassen
faassen at startifact.com
Tue Sep 11 10:37:29 EDT 2007
Hey,
Jan-Wijbrand Kolman wrote:
> I'm "porting" my application to the latest Grok version and suddenly,
> whenever I try to go the http://localhost:8080/applications I get an
> error message.
>
> After a bit of digging, I found that somehow, for some reason, a module
> level function in my application called "handle_cascade" is being
> invoked by the documentation grokking machinery(?).
>
> It seems names starting with 'handle_' are considered special. I'm not
> sure I like that. Can someone explain why these names are special?
This is news to me too. It looks like this is the case in docgrok.py
however - a grokker is defined that looks for things called handle_.
While this is an example I used in Martian, I don't think it would be
good to actually pick up functions. The problem with this approach is
that one JW ran into - you can't define functions that start with that
name anymore.
A better pattern would be to define a docgrok specific base class and
look for subclasses of those. This eliminates the risk of namespace
pollution.
*If* we want to actually grok functions, let's only grok those that are
actually decorated, like the example of @grok.subscriber.
Regards,
Martijn
More information about the Grok-dev
mailing list