[Grok-dev] Re: Making an interface the default module context
Philipp von Weitershausen
philipp at weitershausen.de
Tue Aug 5 10:17:40 EDT 2008
Martijn Faassen wrote:
> Philipp von Weitershausen wrote:
>>> This would introduce auto-association with interfaces. I think that's
>>> a reasonably safe behavior if we require that IContext is extended,
>>> and is more or less analogous to what happens with classes as far as
>>> I can see.
>> Yeah. Well, if somebody's willing to extend grokcore.component as
>> described here, I won't say no :).
> One thing I worry about is as this is an instance, it might
> auto-associate even with an imported interface. We need to make sure
> that this isn't the case.
Indeed. martian's scan_for_classes wisely uses the defined_locally check
for that. If it were extended to scan for interfaces as well, that check
would have to be applied to them as well.
All that said, in my experience apps quickly outgrow the restrictions
that are required for using this automatic mapping of views and other
adapters to implicit contexts.
While it's great to have automatic mapping when you start out and just
write a bunch of classes in one module, I find that when introduce
interfaces, you tend to have so many components anyways that it's wise
to split up the code over multiple modules. At that point you should
also have understood what grok.context() does and why it's necessary.
More information about the Grok-dev