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
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. :)
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)
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
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,