Part of twisted.python View Source
Using the Zope3 API directly is strongly recommended. Everything you need is in the top-level of the zope.interface package, e.g.:
from zope.interface import Interface, implements class IFoo(Interface): pass class Foo: implements(IFoo) print IFoo.implementedBy(Foo) # True print IFoo.providedBy(Foo()) # True
twisted.python.components.registerAdapter
from this module may be used to add to Twisted's global adapter
registry.
twisted.python.components.proxyForInterface
is a factory for classes which allow access to only the parts of another
class defined by a specified interface.
Function | registerAdapter | Register an adapter class. |
Function | getAdapterFactory | Return registered adapter for a given class and interface. |
Function | getRegistry | Returns the Twisted global
zope.interface.adapter.AdapterRegistry instance. |
Class | Adapter | I am the default implementation of an Adapter for some interface. |
Class | Componentized | I am a mixin to allow you to be adapted in various ways persistently. |
Class | ReprableComponentized | Undocumented |
Function | proxyForInterface | Create a class which proxies all method calls which adhere to an interface to another provider of that interface. |
Function | _registered 0 | Return the adapter factory for the given parameters in the given registry, or None if there is not one. |
Function | _registered | Return the adapter factory for the given parameters in the given registry, or None if there is not one. |
Function | _addHook | Add an adapter hook which will attempt to look up adapters in the given registry. |
Function | _removeHook | Remove a previously added adapter hook. |
Class | _ProxiedClassMethod | A proxied class method. |
Class | _ProxyDescriptor | A descriptor which will proxy attribute access, mutation, and deletion
to the original attribute of the object it is being accessed
from. |
An adapter class is expected to implement the given interface, by adapting instances implementing 'origInterface'. An adapter class's __init__ method should accept one parameter, an instance implementing 'origInterface'.
Note that is tied to the *Twisted* global registry, and will thus not find adapters registered elsewhere.
Returns | The hook which was added, for later use with _removeHook . |
Parameters | hook | An object previously returned by a call to _addHook .
This will be removed from the list of adapter hooks. |
zope.interface.adapter.AdapterRegistry
instance.Create a class which proxies all method calls which adhere to an interface to another provider of that interface.
This function is intended for creating specialized proxies. The typical way to use it is by subclassing the result:
class MySpecializedProxy(proxyForInterface(IFoo)): def someInterfaceMethod(self, arg): if arg == 3: return 3 return self.original.someInterfaceMethod(arg)
Parameters | iface | The Interface to which the resulting object will conform, and which the wrapped object must provide. |
originalAttribute | name of the attribute used to save the original object in the resulting
class. Default to original . (type: str ) | |
Returns | A class whose constructor takes the original object as its only argument. Constructing the class creates the proxy. |