[Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results
Shane Hathaway
shane at hathawaymix.org
Mon Sep 8 13:31:19 EDT 2008
Chris Withers wrote:
> Philipp von Weitershausen wrote:
>>> Right, but how do you differentiate adapting a tuple to IBrowserPage
>>> versus adapting obj and request together to IBrowserPage?
>> You don't, I guess. I'd say that multi-adaption is *defined* as the
>> adaption of a tuple.
>
> Well no, I think Dieter suggested the correct solution here in making
> the Interface's __call__ method like this:
>
> def __call__(self,*adapted,default=None,name=None)
That's invalid Python syntax, unfortunately, but this will do what you want:
def __call__(self, *adapted, **kw):
default = kw.pop('default', None)
name = kw.pop('name', None)
if kw:
raise TypeError("__call__() got an unexpected keyword argument")
# ...
This seems like a good idea to me.
Shane
More information about the Zope-Dev
mailing list