Package twisted :: Package python :: Module components :: Class Interface
[show private | hide private]
[frames | no frames]

Class Interface

object --+
         |
        Interface

Known Subclasses:
IResource

Base class for interfaces.

Interfaces define and document an interface for a class. An interface class's name must begin with I, and all its methods should have no implementation code.

Objects that implement an interface should have an attribute __implements__, that should be either an Interface subclass or a tuple, or tuple of tuples, of such Interface classes.

A class whose instances implement an interface should list the interfaces its instances implement in a class-level __implements__.

For example:
   | class IAdder(Interface):
   |     'Objects implementing this interface can add objects.'
   |
   |     def add(self, a, b):
   |         'Add two objects together and return the result.'
   |
   | class Adder:
   |
   |     __implements__ = IAdder
   |
   |     def add(self, a, b):
   |         return a + b
You can call an Interface with a single argument; If the passed object can be adapted to the Interface in some way, the adapter will be returned.
Method Summary
  adaptWith(self, using, to, registry)
(Class method)
    Inherited from object
  __init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)
    Inherited from type
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T

Class Variable Summary
type __metaclass__ = twisted.python.components.MetaInterface

Generated by Epydoc 2.0 on Thu Dec 25 10:59:57 2003 http://epydoc.sf.net