[Twisted-Python] Get an object that provides an interface

Jean-Paul Calderone exarkun at divmod.com
Mon Nov 21 15:09:44 EST 2005

On Mon, 21 Nov 2005 17:52:14 -0200, Gustavo Dagostin da Silva <gds11561 at tj.sc.gov.br> wrote:
>Is it possible to get an object that provides (from a class that implements) a
>interface without mentioning the class? In other words:
>class ISomething(Interface):
>	def method(self):
>		""" Do something
>		"""
>class SomethingImplementor:
>	implements(ISomething)
>	def method(self):
>		print "I exist!!"
>obj = ISomething()
># and obj gets an instance of "SomethingImplementor", without
># mentioning it.
>The documentation of component usage in twisted only mentions interfaces in
>the context where "Adapters" are needed.

See the thread entitled "zope.interface calling an interface with no arguments" on the interface-dev list:



More information about the Twisted-Python mailing list