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

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


On Mon, 21 Nov 2005 17:52:14 -0200, Gustavo Dagostin da Silva <gds11561 at tj.sc.gov.br> wrote:
>Hello,
>
>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:

http://mail.zope.org/pipermail/interface-dev/2005-August/thread.html
http://mail.zope.org/pipermail/interface-dev/2005-September/thread.html

Jean-Paul




More information about the Twisted-Python mailing list