Chris Withers wrote:
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:
Don't guess, just look at the docs that are there.
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 ;-)
It does -- in the interfaces. Like it or not, Zope 3's API *is* well
documented, if you look in the right places: the interfaces. That's what
they're there for.
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
Adapter factories can return None to indicate that adaption has failed.
and that's a "special value" meaning "couldn't adapt", right?
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)
Zope3-dev mailing list