class documentation

class twisted.web._element.Expose: (source)

View In Hierarchy

Helper for exposing methods for various uses using a simple decorator-style callable.

Instances of this class can be called with one or more functions as positional arguments. The names of these functions will be added to a list on the class object of which they are methods.

Instance Variable attributeName The attribute with which exposed methods will be tracked.
Method __init__ Undocumented
Instance Variable doc Undocumented
Method __call__ Add one or more functions to the set of exposed functions.
Method get Retrieve an exposed method with the given name from the given instance.
Class Variable _nodefault Undocumented
Class Method _withDocumentation No summary
attributeName = (source)
The attribute with which exposed methods will be tracked.
def __init__(self, doc=None): (source)

Undocumented

Undocumented

def __call__(self, *funcObjs): (source)

Add one or more functions to the set of exposed functions.

This is a way to declare something about a class definition, similar to zope.interface.implementer. Use it like this:

    magic = Expose('perform extra magic')
    class Foo(Bar):
        def twiddle(self, x, y):
            ...
        def frob(self, a, b):
            ...
        magic(twiddle, frob)

Later you can query the object:

    aFoo = Foo()
    magic.get(aFoo, 'twiddle')(x=1, y=2)

The call to get will fail if the name it is given has not been exposed using magic.

ParametersfuncObjsOne or more function objects which will be exposed to the client.
ReturnsThe first of funcObjs.
_nodefault = (source)

Undocumented

def get(self, instance, methodName, default=_nodefault): (source)

Retrieve an exposed method with the given name from the given instance.

ReturnsA callable object for the named method assigned to the given instance.
RaisesUnexposedMethodErrorRaised if default is not specified and there is no exposed method with the given name.
@classmethod
def _withDocumentation(cls, thunk): (source)

Slight hack to make users of this class appear to have a docstring to documentation generators, by defining them with a decorator. (This hack should be removed when epydoc can be convinced to use some other method for documenting.)

API Documentation for Twisted, generated by pydoctor 20.12.1 at 2021-02-28 19:53:36.