Chris Withers wrote:
Philipp von Weitershausen wrote:
Chris Withers wrote:
Christian Theune wrote:
The problem you have is to provide a specification for the 'str' interface.

There are a couple of problems here...

1. str is both a "function" and a "class"

Nope. It's a class since Python 2.2.

...hence the quotes. It's a "function" in that I want to use it as an adapter that doesn't need to be instantiated by a factory before being used.

All adapters need to be instantiated. A function can serve as much as an adapter factory as a class.

...and factory="str" is wrong for the reasons given above, or, put differently, because str()(1) will tell you that strings aren't callable ;-)

Huh? You got that wrong. IString(1) will call str(1) if provideAdapter(str, (int,), IString).

right, but factory="" registers and adapter factory, not an adapter and provideAdapter registers an adapter directly, correct?

No. You always register a factory which is called upon lookup. That's because adapters are context-dependent and thus need to be instantiated every time you look them up.

-- -- Professional Zope documentation and training
Zope3-dev mailing list

Reply via email to