On Tuesday 18 December 2007, Chris Withers wrote: > Why does the following adapter registration not work? > > <adapter > for=".SomeModule.SomeClass *" > provides=".interfaces.ISomething" > factory=".factories.Factory" > name="something" > /> > > >>> from zope.component import getAdapters > >>> from SomeModule import SomeClass > >>> from interfaces import ISomething > >>> getAdapters((SomeClass('test'),object()),ISomething) > > []
Mmmh, seems like a directive problem: >>> import zope.component >>> class MyClass(object): ... pass ... >>> class MyFactory(object): ... def __init__(self, klass, obj): ... pass ... >>> zope.component.provideAdapter( ... MyFactory, ... adapts=(MyClass, None), ... KeyboardInterrupt >>> import zope.interface >>> class ISomething(zope.interface.Interface): ... pass ... >>> zope.component.provideAdapter( ... MyFactory, ... adapts=(MyClass, None), ... provides=ISomething, ... name='something') >>> zope.component.getAdapters((MyClass(), object()), ISomething) <generator object at 0xb7c56d8c> >>> list(zope.component.getAdapters((MyClass(), object()), ISomething)) [(u'something', <__main__.MyFactory object at 0xb7b4a06c>)] Regards, Stephan -- Stephan Richter CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training _______________________________________________ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users