extension.py |
|
---|---|
A template of a WebCore 2 extension. Only the init method is requried. The class attributes listed below control ordering and activation of other extensions.
The names of method arguments are unimportant; all values are passed positionally. |
class Extension(object):
uses = []
needs = []
always = False
never = False
first = False
last = False
provides = []
extensions = ()
|
Executed to configure the extension. No actions must be performed here, only configuration management. You can also update the class attributes here. It only really makes sense to add dependencies. |
def __init__(self, **config):
super(Extension, self).__init__()
|
Executed to wrap the application in middleware. The first argument is the global context class, not request-local context instance. Accepts a WSGI application as the second argument and must likewise return a WSGI app. |
def __call__(self, context, app):
return app
|
Executed during application startup just after binding the server. The first argument is the global context class, not request-local context instance. Any of the actions you wanted to perform during |
def start(self, context):
pass
|
Executed during application shutdown after the last request has been served. The first argument is the global context class, not request-local context instance. |
def stop(self, context):
pass
|
Called when a SIGHUP is sent to the application. The first argument is the global context class, not request-local context instance. Allows your code to re-load configuration and your code should close then re-open sockets and files. |
def graceful(self, context, **config):
pass
|
Executed during request set-up to populate the thread-local The purpose of the extension ordering is to ensure that methods like these are executed in the correct order. |
def prepare(self, context):
pass
|
Executed as dispatch descends into a tier. The Generally called in series, like:
|
def dispatch(self, context, consumed, handler, is_endpoint):
pass
|
Executed after all extension prepare methods have been called, prior to dispatch. |
def before(self, context):
pass
|
Executed after dispatch has returned and the response populated, prior to anything being sent to the client. Similar to middleware, the first extension registered has its |
def after(self, context):
pass
|
Inspect and potentially mutate the given handler's arguments. The args list and kw dictionary may be freely modified, though invalid arguments to the handler will fail. |
def mutate(self, context, handler, args, kw):
pass
|
Transform outgoing values prior to view lookup. |
def transform(self, context, handler, result):
pass
|
Populate an interactive shell. |
def interactive(self):
return dict()
|
Return an object conforming to the inspector panel API. |
def inspect(self, context):
pass
|