[Interface-dev] Class -> interface adapters, and design question

Jim Fulton jim at zope.com
Mon Apr 19 06:32:03 EDT 2004


Itamar Shtull-Trauring wrote:
> Hi,
> 
> I've started the port of Twisted's components, and I've got some
> questions.
> 
> I can't figure out how to register a class->interface adapter.
> aRegistry.register([Klass], [IFoo], '', AdapterClass) doesn't work.

You want:

   adapter.aRegistry.register([implmentedBy(Klass)], [IFoo], '', AdapterClass)

The first argument is a seqience of specifications.  You get the specification
for a class using implementedBy.

> I decided that Twisted would have its own (global) registry, and append
> it to z.i.interface.adapter_hooks. Make sense?

Is that because you don't want to depend on zope.component?

Note that zope.interface.adapter.AdapterRegistry doesn't actually
provide adapter factory sementics.  That's what
zope.component.adapter.GlobalAdapterService does.  I'm open to providing
those sementics in zope.interface.adapter.

> When the code is starting to actually pass tests and is not in the midst
> of major surgery I'll post link to source.

Cool

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org




More information about the Interface-dev mailing list