[Zope3-dev] Re: adapter registration - sort of works :-S

2006-11-16 Thread Philipp von Weitershausen
Chris Withers wrote: Chris Withers wrote: Jean-Marc Orliaguet wrote: once you have that utility / adapter you should be able to call it like: converter = getAdapterFor(123, type=IToStringConverter) strResult = converter.convert(123) Not quite, what I'm looking to do is more along the

Re: [Zope3-dev] Re: adapter registration - sort of works :-S

2006-11-16 Thread Chris Withers
Philipp von Weitershausen wrote: from zope.component import provideAdapter provideAdapter(str,(int,),str) from zope.component import getAdapter getAdapter(123,str) '123' Yay! That's _exactly_ what I want. And that's exactly what I meant -- and wrote about half way up the thread. :)

Re: [Zope3-dev] Re: adapter registration - sort of works :-S

2006-11-16 Thread Philipp von Weitershausen
Chris Withers wrote: provideAdapter(to_date,(str,int),DateTime) This registers a multi adapter for (a_string, an_integer), like views are multi-adapters for (context, request). You want to say: provideAdapter(to_date, (str,), DateTime) provideAdapter(to_date, (int,), DateTime)

[Zope3-dev] Re: adapter registration - sort of works :-S

2006-11-16 Thread Jean-Marc Orliaguet
Philipp von Weitershausen wrote: Chris Withers wrote: Chris Withers wrote: Jean-Marc Orliaguet wrote: once you have that utility / adapter you should be able to call it like: converter = getAdapterFor(123, type=IToStringConverter) strResult = converter.convert(123) Not quite, what I'm

Re: [Zope3-dev] Re: adapter registration - sort of works :-S

2006-11-16 Thread Paul Winkler
On Thu, Nov 16, 2006 at 10:21:09AM +0100, Philipp von Weitershausen wrote: How would I _really_ return None from an adapter? You don't. You call the adaption with a default value (e.g. None) to cover for the coudln't adapt case: getAdapter('moo', DateTime, None) That doesn't work,