pyfarm.master.application module

Application

Contains the functions necessary to construct the application layer classes necessary to run the master.

class pyfarm.master.application.SessionMixin[source]

Bases: object

Mixin which adds a _session attribute. This class is provided mainly to limit issues with circular imports.

class pyfarm.master.application.UUIDConverter(map)[source]

Bases: werkzeug.routing.BaseConverter

A URL converter for UUIDs. This class is loaded as part of the Flask application setup and may be used in url routing:

@app.route('/foo/<uuid:value>')
def foobar(value):
    pass

When a request such as GET /foo/F9A63B47-66BF-4E2B-A545-879986BB7CA9 is made UUIDConverter will receive value to to_python() which will then convert the string to an instance of UUID.

to_python(value)[source]
to_url(value)[source]
pyfarm.master.application.before_request()[source]

Global before_request handler that will handle common problems when trying to accept json data to the api.

pyfarm.master.application.get_api_blueprint(url_prefix=None)[source]

Constructs and returns an instance of Blueprint for routing api requests.

Parameters:url_prefix (string) – The url prefix for the api such as /api/v1. If not provided then value will be derived from the api_prefix configuration variable.
pyfarm.master.application.get_application(**configuration_keywords)[source]

Returns a new application context. If keys and values are provided to config_values they will be used to override the default configuration values or create new ones

>>> app = get_application(TESTING=True)
>>> assert app.testing is True
Parameters:setup_appcontext (bool) – If True then setup the flask.g variable to include the application level information (ex. g.db)
pyfarm.master.application.get_login_manager(**kwargs)[source]

Constructs and returns an instance of LoginManager. Any keyword arguments provided will be passed to the constructor of LoginManager

pyfarm.master.application.get_login_serializer(secret_key)[source]

Constructs and returns and instance of URLSafeTimedSerializer

pyfarm.master.application.get_sqlalchemy(app=None, use_native_unicode=True, session_options=None)[source]

Constructs and returns an instance of SQLAlchemy. Any keyword arguments provided will be passed to the constructor of SQLAlchemy