[Grok-dev] you can comma separate directives
Brandon Craig Rhodes
brandon at rhodesmill.org
Thu May 1 17:25:30 EDT 2008
What fun! It just occurred to be that, because directives just
introspect the stack, but don't return any useful value "into" the
class-declaration code block they're part of, you can stack them on a
single line with commas:
class Fish(grok.View):
grok.context(MyApp), grok.name('fish')
That will be helpful the next time a stack of directives threatens to
push my actual code down off of the bottom of the screen.
I suppose that would mean that they would work *wherever* in a line of
class-declaration code they were evaluated, even if they were part of
an expression, or an argument to a function. So the above could be
written:
class Fish(grok.View):
grok.context(grok.name('fish') or MyApp)
Which is useless, of course, but silly examples like this help me get
straight about what really makes directives work: simply by being
invoked *somewhere* on a line of code inside of a class declaration,
they get automatic access the class object.
Somewhere in the realm of possibilities this opens up is an
interesting syntax construction that I'm not thinking of. :-)
--
Brandon Craig Rhodes brandon at rhodesmill.org http://rhodesmill.org/brandon
More information about the Grok-dev
mailing list