# ``twisted`.`python`.`components`.`Componentized``

class documentation

`class Componentized: (source)`

Known subclasses: `twisted.python.components.ReprableComponentized`, `twisted.web.server.Request`, `twisted.web.server.Session`, `twisted.web.static.Registry`

View In Hierarchy

I am a mixin to allow you to be adapted in various ways persistently.

I define a list of persistent adapters. This is to allow adapter classes to store system-specific state, and initialized on demand. The getComponent method implements this. You must also register adapters for this class for the interfaces that you wish to pass to getComponent.

Many other classes and utilities listed here are present in Zope3; this one is specific to Twisted.

Method | `__conform__` | Undocumented
Method | `__init__` | Undocumented
Method | `addAdapter` | Utility method that calls addComponent. I take an adapter class and instantiate it with myself as the first argument.
Method | `addComponent` | Add a component to me, for all appropriate interfaces.
Method | `getComponent` | Create or retrieve an adapter for the given interface.
Method | `locateAdapterClass` | Undocumented
Method | `removeComponent` | Remove the given component from me entirely, for all interfaces for which it has been registered.
Method | `setAdapter` | Cache a provider for the given interface, by adapting `self` using the given adapter class.
Method | `setComponent` | Cache a provider of the given interface.
Method | `unsetComponent` | Remove my component specified by the given interface class.
Class Variable | `persistenceVersion` | Undocumented
Instance Variable | `_adapterCache` | Undocumented

def __conform__(self, interface): (source)

Undocumented

def __init__(self): (source)
overridden in `twisted.python.components.ReprableComponentized`, `twisted.web.server.Request`, `twisted.web.server.Session`, `twisted.web.static.Registry`

Undocumented

def addAdapter(self, adapterClass, ignoreClass=0): (source)
Utility method that calls addComponent. I take an adapter class and instantiate it with myself as the first argument.

Returns
The adapter instantiated.

def addComponent(self, component, ignoreClass=0): (source)

Add a component to me, for all appropriate interfaces.

In order to determine which interfaces are appropriate, the component's provided interfaces will be scanned.

If the argument 'ignoreClass' is True, then all interfaces are considered appropriate.

Otherwise, an 'appropriate' interface is one for which its class has been registered as an adapter for my class according to the rules of getComponent.

def getComponent(self, interface, default=None): (source)

Create or retrieve an adapter for the given interface.

If such an adapter has already been created, retrieve it from the cache that this instance keeps of all its adapters. Adapters created through this mechanism may safely store system-specific state.

If you want to register an adapter that will be created through getComponent, but you don't require (or don't want) your adapter to be cached and kept alive for the lifetime of this Componentized object, set the attribute 'temporaryAdapter' to True on your adapter class.

If you want to automatically register an adapter for all appropriate interfaces (with addComponent), set the attribute 'multiComponent' to True on your adapter class.

def locateAdapterClass(self, klass, interfaceClass, default): (source)

Undocumented

def removeComponent(self, component): (source)
Remove the given component from me entirely, for all interfaces for which it has been registered.

Returns
a list of the interfaces that were removed.

def setAdapter(self, interfaceClass, adapterClass): (source)
Cache a provider for the given interface, by adapting `self` using the given adapter class.
def setComponent(self, interfaceClass, component): (source)
Cache a provider of the given interface.
def unsetComponent(self, interfaceClass): (source)
Remove my component specified by the given interface class.
persistenceVersion: `int` = (source)

Undocumented

_adapterCache: `dict` = (source)

Undocumented