Package twisted :: Package web :: Module static :: Class Registry

[show private | hide private]
[frames | no frames]

## Class Registry

    Versioned --+
                |
    Componentized --+
                    |
        Versioned --+
                    |
                   Registry

I am a Componentized object that will be made available to internal Twisted file-based dynamic web content such as .rpy and .epy scripts.

Method Summary
| `__init__(self)`
| ``__getstate__`(self, dict)` Get state, adding a version number to it on its way out. (inherited from `Versioned`)
| `__setstate__(self, state)` (inherited from `Versioned`)
| ``addAdapter`(self, adapterClass, ignoreClass)` Utility method that calls addComponent. (inherited from `Componentized`)
| ``addComponent`(self, component, ignoreClass)` Add a component to me, for all appropriate interfaces. (inherited from `Componentized`)
| `cachePath(self, path, rsrc)`
| `getCachedPath(self, path)`
| ``getComponent`(self, interface)` Very similar to Componentized.getComponent, with a little magic.
| `locateAdapterClass(self, klass, interfaceClass, default)` (inherited from `Componentized`)
| ``removeComponent`(self, component)` Remove the given component from me entirely, for all interfaces which it has been registered. (inherited from `Componentized`)
| `setAdapter(self, interfaceClass, adapterClass)` (inherited from `Componentized`)
| `setComponent(self, interfaceClass, component)` (inherited from `Componentized`)
| ``unsetComponent`(self, interfaceClass)` Remove my component specified by the given interface class. (inherited from `Componentized`)
| `upgradeToVersion1(self)`
| ``versionUpgrade`(self)` (internal) Do a version upgrade. (inherited from `Versioned`)
| ``_grabService`(self, svc, sclas)` Find an instance of a particular class in a service collection and all subcollections.

Class Variable Summary
`int` | `persistenceVersion`

Method Details

### getComponent(self, interface)

Very similar to Componentized.getComponent, with a little magic.

This adds the additional default behavior that if no component already exists and 'interface' is a subclass of `twisted.internet.app.ApplicationService`, it will automatically scan through twisted.internet.app.theApplication and look for instances of 'interface'.

This has the general effect that if your web script (in an RPY, EPY, or anywhere else that a Registry is present) wishes to locate a Service in a default webserver, it can say 'registry.getComponent(MyServiceClass)' and if there is a service of that type registered with the Application, it will be found. Additionally, in a more complex server, the registry can be explicitly given a service to locate for that interface using setComponent(MyServiceClass, myServiceInstance). Separate File instances can be used to represent access to different services.

### _grabService(self, svc, sclas)

Find an instance of a particular class in a service collection and all subcollections.

Class Variable Details

### persistenceVersion

  Type:
    `int`
  Value:

        1

Generated by Epydoc 1.1 on Sat Feb 15 21:19:29 2003 | http://epydoc.sf.net