Routers

flask_worker.set_route

def flask_worker.set_route(func) [source]

The @set_route decorator bookmarks the current function call. Specifically, it sets the Router's func to the the current function and stores the args and kwargs.

flask_worker.RouterMixin

class flask_worker.RouterMixin(func, *args, **kwargs) [source]

Mixin for Router models. A Router manages a series of function calls initiated by a view function. These function calls must be methods of the Router.

Suppose a view function initiates a series of function calls which include calling a Router. The Router can 'bookmark' its methods; if this Router is called in the future, it will pick up its series of function calls at the bookmarked method.

Parameters: func : callable

The function executed when the Router is called.

*args, **kwargs :

Arguments and keyword arguments passed to func.

Attributes: func : callable

Set from the func parameter.

args : list, default=[]

Set from the *args parameter.

kwargs : dict, default={}

Set from the **kwargs parameter.

init_func : callable

Set from the func parameter. func is reset to init_func when the Router's reset method is called.

init_args : list, default=[]

Set from the *args parameter. args is reset to init_args when the Router's reset method is called.

init_kwargs : dict, default={}

Similarly defined.

Methods

__call__(self) [source]

Calls self.func, passing in self.args and self.kwargs.

Returns: page_html : str

Html of the page returned by the current route.

reset(self) [source]

Reset self.func, self.args, and self.kwargs to their initial values.

Returns: self : flask_worker.RouterMixin