Defernia uses Flask as framework for web frontend. It depends on Werkzeug and Jinja2 also.
See also
(defernia.world.repo.RepositoryDirectory) The global variable that stores the world repository directory object.
(defernia.orm.Session) The global variable that stores the SQLAlchemy session.
(sqlalchemy.engine.base.Engine) The global variable that stores SQLAlchemy dtabase engine.
The dict of blueprints to be registered. Keys are import names in string, and values are keyword arguments for flask.Flask.register_blueprint() method.
blueprints = {'module.name:var': {'url_prefix': '/path'},
'module.name2:var2': {}}
See also
The list of WSGI middlewares to hook in. Its elements are import names in string.
wsgi_middlewares = ['defernia.web.wsgi:MethodRewriteMiddleware']
See also
The dict of serializers for content types. Keys are MIME types like application/json, and values are functions that encode a value into the paired type, or a string which is a postfix of the template filename e.g. '.html', '.xml'. If value is a string that doesn’t start with period (.), it will be interpreted as import name.
content_types = {'application/json': json.dumps,
'text/yaml': 'defernia.web.serializers:yaml',
'text/html': '.html',
'text/xml': '.xml'}
See also
An application factory. It sets up the application then returns the application.
app = create_app(config_filename='prod.cfg')
Instead you pass an argument config_filename, it can be used as decorator-style as well:
@create_app
def app(app):
app.debug = True
app.config['MAGIC_NUMBER'] = 1234
Parameters: |
|
---|---|
Returns: | a WSGI application |
Return type: |
Gets defernia.world.repo.RepositoryDirectory object from the config.
Parameters: | config (flask.Config, dict) – the configuration that contains 'REPODIR_PATH' |
---|---|
Returns: | world repository directory object |
Return type: | defernia.world.repo.RepositoryDirectory |
Gets SQLAlchemy Engine object from the config.
Parameters: | config (flask.Config, dict) – the configuration that contains 'DATABASE_URL' or 'ENGINE' |
---|---|
Returns: | SQLAlchemy database engine |
Return type: | sqlalchemy.engine.base.Engine |
See also
SQLAlchemy — Engine Configuration
The decorator that registers function into before_request_funcs.
The decorator that registers function into after_request_funcs.
Sets the g.world_repodir, g.session and g.database_engine global variables before every request.
The generic content type version of flask.render_template() function. Unlike flask.render_template(), it takes one more required parameter, value, for generic serialization to JSON-like formats. And template_name doesn’t include its postfix.
render('user/profile', user, user=user)
Parameters: |
|
---|
See also
Constant content_types