[Zope3-dev] wildcard adapter
Marius Gedminas
mgedmin at b4net.lt
Wed Jan 17 12:30:15 EST 2007
On Wed, Jan 17, 2007 at 06:37:52AM -0800, Martin Aspeli wrote:
> Chris Withers wrote:
> > I was wondering if someone could give me a definitive explanation of
> > what the following means:
> >
> > <adapter
> > for="* ISomething *"
> > ...
> >
> > ...means?
> >
> > Is the following equivalent:
> >
> > provideAdapter(...,adapts=(None,ISomething,None),...)
>
> No, but this is:
>
> provideAdapter(...,adapts=(Interface, ISomething, Interface),...)
As far as I know provideAdapter treats None the same way as Interface.
I've used this pattern a few times:
from zope.adapter import adapts, provideAdapter
from zope.interface import implements
...
class SomeAdapter(object):
adapts(None)
implements(IFoo)
...
provideAdapter(SomeAdapter)
BTW passing interfaces to provideAdapter/<adapts> is out of fashion. I
prefer using zope.component.adapts and zope.interface.implements (or
zope.component.adapter and zope.interface.implementer, when my adapter
is a function rather than a class).
Marius Gedminas
--
America and England are two countries separated by a common language.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zope3-dev/attachments/20070117/267b344a/attachment.bin
More information about the Zope3-dev
mailing list