[Zope3-dev] Re: [Zope3-checkins] CVS: Zope3/src/zope/app/services - adapter.py:1.13

Steve Alexander steve@cat-box.net
Sun, 30 Mar 2003 09:35:24 +0200


Stephan Richter wrote:
> On Friday 28 March 2003 19:42, Sidnei da Silva wrote:
> 
>>Log Message:
>>I know that I broke the tests, but Ive sent the patch to the mailing list
>>and none committed the fix, so I did. I dont know how to fix this test.
> 
> 
> Guys,
> 
> I have been looking at this test and try to fix it to help out Sidnei a bit, 
> and I must say that the behavior the test is asking for is a bit tricky.
> 
> I have an object O1 that implements interface I1. if I now ask for 
> queryAdapter(O1(), I1, name="foo") it expects to return the object (according 
> to the test). I am not sure this is correct. I think this should fail, unless 
> no name is passed. What do you think? Once we agree on a behavior, I make the 
> changes accordingly.

If I have an object O1 that implements I1, queryAdapter(O1, I1) returns 
O1 without using the Adapters service.

However, queryAdapter(O1, I1, name='anything') will always use the 
Adapters service. So, except in very special cases, O1 will not be 
returned. The call to queryAdapter will return None.

There are unit tests for getAdapter and queryAdapter that spell out this 
behaviour.

See Zope3/src/zope/component/tests/test_api.py : testNamedAdapter(), 
line 100.

--
Steve Alexander