1
def method(method_class):
2
"""Decorator to use to mark an API method.
4
When invoking L{Registry.scan} the classes marked with this decorator
5
will be added to the registry.
7
@param method_class: The L{Method} class to register.
10
def callback(scanner, name, method_class):
11
if method_class.actions is not None:
12
actions = method_class.actions
16
if method_class.versions is not None:
17
versions = method_class.versions
21
for action in actions:
22
for version in versions:
23
scanner.registry.add(method_class,
27
from venusian import attach
28
attach(method_class, callback, category="method")
33
"""Handle a single HTTP request to an API resource.
35
@cvar actions: List of actions that the Method can handle, if C{None}
36
the class name will be used as only supported action.
37
@cvar versions: List of versions that the Method can handle, if C{None}
38
all versions will be supported.
43
def invoke(self, call):
44
"""Invoke this method for executing the given C{call}."""
45
raise NotImplemented("Sub-classes have to implement the invoke method")
47
def is_available(self):
48
"""Return a boolean indicating wether this method is available.
50
Override this to dynamically decide at run-time whether specific
51
methods are available or not.