[Grok-dev] grok directive for only grokking during development mode

Leonardo Rochael Almeida leorochael at gmail.com
Tue Feb 5 19:38:53 EST 2008

+1 to grok.tag('sometag') (wasn't it going to be 'label' before? :-)

As for:

> <grok:grok package="." include_tags="a b" exclude_tags="c d" />

I don't much mind the attributes as long as we can make them as
unnecessary as possible. for that we could do:

  class MyTag(grok.Tag):
      grok.name('mytag') # automatic
      auto = False # defults to True

If "auto" is not True, 'tagname' must be included in 'include_tags' to
be activated. Otherwise it's activated unless in 'exclude_tags'.

The grok.grok() call should also accept "include_tags" and
"exclude_tags" optional parameters.

-1 to grok.devel(), unless as alias to grok.tag('devel'), where
'devel' would be an already existing grok.Tag with auto=False.

Not sure whether I'd prefer the grok.Tag declarations to be mandatory.
It'd avoid typos on tag names, but perhaps it would be too much
explicit configuration. Unless we have enough pre-configured tags to
cover most cases ('on', 'off', 'devel', 'test'...).

Cheers, Leo

On Feb 5, 2008 5:28 PM, Martijn Faassen <faassen at startifact.com> wrote:
> Hi there,
> I think it would be useful to have a directive that can be put on a
> component so it only gets grokked during development mode, not in
> production mode. Something like this:
> class MyView(grok.View):
>     grok.devel()
> 'MyView' would only be grokked and thus only registered in development
> mode, not in production mode. This requires us figuring out what
> development-mode and production-mode currently mean in Zope and how to
> detect it during the grokking process...
> Or perhaps we should generalize this to the tagging story we already
> discussed quite a while ago:
> class MyView(grok.View):
>     grok.tag('devel')
> the 'grok.tag' directive would receive one or more tags. Tags are then
> used to determine what gets grokked or not, perhaps like this:
> <grok:grok package="." include_tags="a b" exclude_tags="c d" />
> It'd be nice to be able to spell out the include_tags and exclude_tags
> in Python somehow, so that we don't end up writing a lot of ZCML in the
> end. :)
> Some tags could be given special meaning, like 'devel', which means
> "don't include during production mode". Anyway, a bit of design to work out.
> What do people think? Ideas? Suggestions?
> Someone volunteering for its implementation? :)
> ...

More information about the Grok-dev mailing list