API

This part of the documentation covers all the interfaces of Mara App. For parts where the package depends on external libraries, we document the most important right here and provide links to the canonical documentation.

App

class mara_app.app.MaraApp
__init__()
disable_caching()

Disable caching for dynamic content (not static files). See https://stackoverflow.com/questions/23112316/using-flask-how-do-i-modify-the-cache-control-header-for-all-output/37331139#37331139

patch_flask_url_for()

Caches calls to flask.url_for because it’s kind of slow

https://stackoverflow.com/questions/16713644/why-is-flask-url-for-too-slow

register_blueprints()

Searches for all declared blueprints and adds them to the app

register_commands()

Searches for all declared click commands and adds them to the app, grouped by package

register_error_handlers()

Sets up error pages for all http exceptions

register_page_layout()

Adds a global layout with navigation etc. to pages

mara_app.app.module_functionalities(module: module, MARA_XXX: str, type) []

Returns some functionalities of a module that is declared in a MARA_XXX variable or function

module.MARA_XXX can be - a function that returns a list or dict - a list - a dict

Monkey patch

mara_app.monkey_patch.patch(original_function: Callable) Callable

A decorator for replacing a function in another module

Examples

>>> # in some_package.some_module:
... def some_function(x):
...     return x + 1
>>> some_package.some_module.some_function(1)
2
>>> @patch(some_package.some_module.some_function)
... def new_function(x):
...      return x + 2
>>> some_package.some_module.some_function(1)
3
>>> # equivalent:
>>> patch(some_package.some_module.some_function)(lambda x: x + 2)
Parameters

original_function – The function or method to patch

Returns

The replaced function

mara_app.monkey_patch.wrap(original_function: Callable) Callable

A decorator for wrapping a function in another module

Examples

>>> # in some_package.some_module:
... def some_function(x):
...     return x + 1
>>> some_package.some_module.some_function(1)
2
>>> @wrap(some_package.some_module.some_function)
... def new_function(original_function, x):
...      return original_function(x) + 1
>>> some_package.some_module.some_function(1)
3
Parameters

original_function – The function or method to wrap

Returns

The wrapped function