streamline.base

This module contains the base class which is used by all other class-based route handler classes.

class streamline.base.NonIterableResponseMixin

This mixin prevents the response data from being iterated upon byte-by-byte by bottle, which in case of large responses has a big performance impact, by wrapping the response data in a list.

class streamline.base.NonIterableRouteBase(*args, **kwargs)

Provides the exact same functionality as RouteBase, only with NonIterableResponseMixin included, so that large response bodies are returned more efficiently.

streamline.base.Route

alias of RouteBase

class streamline.base.RouteBase(*args, **kwargs)

Base class for class-based route handlers. This class produces iterable objects which are initialized with request parameters, and perform the parameter processing and constructing the response body.

When the response is handled by bottle, the object is iterated using the __iter__() method. Therefore, this object may be turned into a lazy object simply by postponing any evaluation until the the method is called.

static abort(code=500, text='Unknown Error.')

Aborts execution and causes a HTTP error.

static after(fn)

Register a function as an after-create hook. After-create hooks are invoked after the create_response call, before iteration over the response body begins. They take the route handler object as the only argument, and their return value is ignored.

static before(fn)

Register a function as a before-create hook. Before-create hooks are invoked before the create_response call. They take the route handler object as the only argument, and their return value is ignored.

bottle = <module 'bottle' from '/home/docs/checkouts/readthedocs.org/user_builds/bottle-streamline/envs/latest/lib/python2.7/site-packages/bottle-0.12.9-py2.7.egg/EGG-INFO/scripts/bottle.py'>
classmethod get_generic_name()

Returns a generic name that can be used for naming a route. This name is in the <module_name>:<decamelized_class_name> format. For example if we have a class that is named MyRoute in a module called beans, the resulting generic name will be beans:my_route.

classmethod get_name()

Return the value of name attribute and fall back on a generic name returned by get_generic_name() class method.

classmethod get_path()

Return the value of path attribute.

static redirect(url, code=None)

Aborts execution and causes a 303 or 302 redirect, depending on the HTTP protocol version.

classmethod route(path=None, name=None, app=None, **kwargs)

Register a route by using class’ configuration. This method will take an optional path, optional route name, and optional app object, and register a route for the specified path using class properties.

If path is not specified, a path will be obtained by invoking the get_path() class method. Similarly, if name is not specified, it will be obtained by invoking the get_name() class method. The default app that is used when app argument is missing is the Bottle’s defalt app.

The handler is registered for http verbs (e.g., GET, POST) for which a lower-case method name exists that matches the verb.

List of plugins that should be applied or skipped can be specified by include_plugins and exclude_plugins properties respectively. These properties should be iterables containing the plugin names as per bottle API.

streamline.base.after(fn)

Decorator that register a function as an after hook.

Example:

@after
def myhook(route):
    pass
streamline.base.before(fn)

Decorator that registers a function as a before hook.

Example:

@before
def myhook(route):
    pass