[Grok-dev] Re: Making an interface the default module context
Philipp von Weitershausen
philipp at weitershausen.de
Mon Aug 4 06:32:29 EDT 2008
Martin Aspeli wrote:
> Philipp von Weitershausen <philipp <at> weitershausen.de> writes:
>
>> If you're trying to find implicit contexts that are interfaces, it'd be
>> easier to look for interfaces that extend a certain interface
>
> How about looking for cases where either the interface or a base interface
> provides IContext?
It seems easier to check if the interface extends IContext
> On a related note, I think it'd be nice to be able to do:
>
> class IFoo(Interface):
> grok.interface_provides(IContext)
>
> which would be equivalent ot
>
> class IFoo(Interface):
> pass
> alsoProvides(IFoo, IContext)
I don't see the necessity to invent a syntax for this right now.
>>> I'm sure it can be done. My question is whether it's a good idea and
>>> something worth having in Grok itself.
>> Maybe. If the function above were generalized a bit, it could have a
>> place in grokcore.component or martian. We should see if this pattern
>> comes up more often, though, and if it actually solves your problem.
>
> Agree. I think it's useful in the case where you want to provide a view or
> viewlet or adapter on a marker interface, certainly.
>
> On the other hand, it's not so hard to write grok.context(IFoo). :)
Indeed.
At least for Grok I personally don't have the intent of changing the
implicit context rules. That doesn't mean you couldn't explore
alternatives and enlighten us with some lessons learned :). For Grok I'd
personally prefer a bit more conservatism right now. We *are* trying to
get towards a 1.0 release, after all, and have other things on our list
for that.
More information about the Grok-dev
mailing list