[Zope-dev] improving the utility and adapter lookup APIs
Tres Seaver
tseaver at palladion.com
Fri Nov 27 02:36:51 EST 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Christian Theune wrote:
> On 11/25/2009 08:51 PM, Fabio Tranchitella wrote:
>> * 2009-11-25 19:35, Tres Seaver wrote:
>>>>> IFoo()
>>>>> IFoo(x)
>>>>> IFoo(x, y)
>>> You can't use an arbitrary number of positional arguments for the
>>> contexts, because we need to support the named / default cases too.
>> I'm probably saying something very stupid... What's wrong with the it?
>> Can't we define something like:
>>
>> def __call__(self, *args, **kw):
>> ....
>>
>> to get a multi adapter in this way?
>>
>> IFoo(x, y, default=None, name='something')
>
> That's what I thought of as well. The __call__ signature isn't as
> expressive as before with that but I'm relatively sure it's a valid
> implementation of Thomas' suggestions.
>
> Tres?
Two issues:
- - The proposed spelling weakens documentation / enforceabiliy of the
contract ('**kw' doesn't tell you what the allowed keys are, and in
fact implies that you can pass arbitrary keys).
- - It's backward-incompatible: there are cases in the wild using
'default' as a positional parameter.
Tres.
- --
===================================================================
Tres Seaver +1 540-429-0999 tseaver at 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
iEYEARECAAYFAksPgY0ACgkQ+gerLs4ltQ5X9QCdF7X3safMgFuofqjQuOiFfUS+
eEgAn0PbN3cNNdoYiuZh5h86AyXwnP7m
=mdBp
-----END PGP SIGNATURE-----
More information about the Zope-Dev
mailing list