[Twisted-Python] adapt from more than one interface

Esteve Fernandez esteve at sindominio.net
Sat Apr 11 16:41:35 EDT 2009

Hi all. I have a bunch of services, which implement a set of interfaces, and I 
use a bunch of adapters to turn them into factories, making those services 

The interface/adapter stuff works great and I'm able to expose those services 
to several protocols, without changing a single line in them. However, some 
of the protocols need some extra information to be passed, so I have to do 

factory = IFooFactory(myService)
factory.bar = "some value"

it works, but I'd rather use this:

factory = IFooFactory(myService, configurationObject)

which would take a second argument, an object implementing another interface 
(e.g. IConfigurationDescriptor), containing all the necessary information for 
that adapter. I don't want to put that information in the service, as it's 
only useful to the protocol and would tie the service to a particular 

In order to implement this, registerAdapter would have to be able to take a 
tuple of interfaces, like this:

    (IFooService, IConfigurationDescriptor),

would that feature make sense? If so, I'll file an issue right now :-)


More information about the Twisted-Python mailing list