[Grok-dev] Re: Making an interface the default module context

Martin Aspeli optilude at gmx.net
Mon Aug 4 05:47:13 EDT 2008


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?

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'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). :)

Martin




More information about the Grok-dev mailing list