[Grok-dev] Re: is automatic context detection harmful?

Martijn Faassen faassen at startifact.com
Wed Aug 29 09:17:05 EDT 2007


Hoi,

[the reference]

On 8/28/07, Sebastian Ware <sebastian at urbantalk.se> wrote:
> Would it be possible to generate such a reference by introspection,
> integrating it with the admin API-doc?

I don't think it's a good idea to auto generate a reference of this
nature. I think we can do much better if we write it by hand.

That said, what I do think would be very useful is if the admin UI
actually presented the grok directives in its UI.

So, if you go to a particular content object, you'll see something like:

views

  * index

  * edit

And then if you click on 'index', you'll see something like this:

dotted name: foo.bar.Index

class Index(grok.View):
    grok.name('Index')
    grok.context(SomeClass)
    grok.permission('zope.Public')

i.e. the admin UI shows *all* the explicit settings even if they are
not explicit int he code. This is a good way to learn about the
available directives and what they do. In order to show the defaults,
we could render the directives in a different color if they are
actually the default and thus don't have to be written out in the
code.

This takes a bit of reverse engineering of the directive state from
the state of the component architecture, using the component
architecture API. To determine whether grok.context can be left out
the module will also need to be scanned to determine whether there's
only a single model available, etc. Or actually, I imagine the __grok_
annotations made on the classes can help to deduce this information.
If not now, we can always introduce a new one that helps with this.

Regards,

Martijn


More information about the Grok-dev mailing list