-----BEGIN PGP SIGNED MESSAGE-----
Leonardo Rochael Almeida wrote:
> Funny you should mention this, I've got this idea bugging for a few
> weeks now, after the last thread:
> Have the zope.interface package expose a single overridable hook:
> def getInterfaceAttribute(iface, name, default):
> This method would be called by any attempt to look up an interface
> attribute that isn't provided by zope.interface itself. For example:
> IFoo.adapter(bar, default=baz)
> Would be the almost the same as:
> getInterfaceAttribute(IFoo, 'adapter', default=somemarker)(bar, default=baz)
> That is unless getInterfaceAttribute(IFoo, 'adapter') returned the
> passed-in marker which would instruct zope.interface to raise an
> AttributeError instead.
> In turn, "zope.component" could then provide a getInterfaceAttribute()
> implementation that called:
> getAdapter(IFoo, interface=IInterfaceMethod, name='adapter')
> Yes, the first parameter above is the original interface. The
> IInterfaceMethod is an interface defining __call__(*args, **kw)
> This idea would also allow one to define named adapters for
> IInterfaceMethod to, for instance, "__call__" or "__add__", such that
> the semantics of "IFoo(...)" or "IFoo + IBar" could also be changed.
> Perhaps entry points could be used to provide getInterfaceAttribute
> implementations, and if multiple entry points are present, each would
> be called in turn to attempt to provide the attributes of an
> interface, but maybe this is too much flexibility...
> Just an idea...
I had originally contemplated replacing the current adapter hook with a
more generic hook: the __call__ of interface would delegate to this hook
for its semantics.
Given that the choice to use __call__ is not widely enough accepted, I
think something like your solution makes sense. I'm not sure that
hooking __getattr__ is going to be performant enough, but a similar
mechanism probably could be made fast enough.
Tres Seaver +1 540-429-0999 tsea...@palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
Zope-Dev maillist - Zope-Dev@zope.org
** No cross posts or HTML encoding! **
(Related lists -