Philipp von Weitershausen wrote:
>>> from zope.component import provideAdapter
>>> from zope.component import getAdapter
Yay! That's _exactly_ what I want.
And that's exactly what I meant -- and wrote about half way up the
Yeah, but the words were wrong, so I didn't grok it.
A simple example as above would probably have done it ;-)
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)
Ahhhh... okay, I had to guess from this:
Help on function provideAdapter in module zope.component:
provideAdapter(factory, adapts=None, provides=None, name='')
TypeError: iteration over non-sequence
I guessed the wrong use of the sequence :-(
Shame provideAdapter doesn't have a docstring ;-)
Okay, so now I can do what I want:
('moo', <class DateTime.DateTime.DateTime at 0x00E73600>, u'')
I'm guessing this is 'cos my adapter is returning None and that's a
"special value" meaning "couldn't adapt", right?
How would I _really_ return None from an adapter?
Simplistix - Content Management, Zope & Python Consulting
Zope3-dev mailing list