tubes._components module documentationtubes
Various component utilities.
| Function | _registryActive | A context manager that activates and deactivates a zope adapter registry for the duration of the call. |
| Function | _registryAdapting | Construct a Zope Interface adapter registry. |
A context manager that activates and deactivates a zope adapter registry for the duration of the call.
For example, if you wanted to have a function that could adapt
IFoo to IBar, but doesn't expose that adapter
outside of itself:
def convertToBar(maybeFoo):
with _registryActive(_registryAdapting((IFoo, IBar, fooToBar))):
return IBar(maybeFoo)
| Parameters | registry | The registry to activate. (type: AdapterRegistry) |
| Returns | (type: ) | |
| Note | This isn't thread safe, so other threads will be affected as well. | |
Construct a Zope Interface adapter registry.
For example, if you want to construct an adapter registry that can
convert IFoo to IBar with
fooToBar.
| Parameters | fromToAdapterTuples | A sequence of tuples of (fromInterface, toInterface,
adapterCallable), where fromInterface and
toInterface are IInterfaces,
and adapterCallable is a callable that takes one argument
which provides fromInterface and returns an object providing
toInterface. (type: tuple of 3-tuples of (Interface, Interface,
callable)) |
| Returns | an adapter registry adapting the given tuples. (type: AdapterRegistry) | |