LangDev uses Flask as framework for web frontend. It depends on Werkzeug and Jinja2 also.
See also
(langdev.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 by default. Keys are import names in string, and values are keyword arguments for flask.Flask.register_blueprint() method.
blueprints = {'module.name:blueprint': {'url_prefix': '/path'},
'module.name2:blueprint2': {}}
It can be extended by BLUEPRINTS configuration also:
BLUEPRINTS = {'module.name:var': {}}
See also
The list of WSGI middlewares to hook in. Its elements are import names in string.
wsgi_middlewares = ['langdev.web.wsgi:MethodRewriteMiddleware']
It can be extended by WSGI_MIDDLEWARES configuration as well.
WSGI_MIDDLEWARES = ['werkzeug.contrib.fixers.ProxyFix']
See also
Similar to flask.Flask.before_request_funcs attribute. It is for lazy loading of global before_request_funcs list.
Similar to flask.Flask.after_request_funcs attribute. It is for lazy loading of global after_request_funcs list.
It is for lazy loading of global error_handlers list.
Internal storage dictionary for template_filter() decorator.
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': 'langdev.web.serializers:yaml',
'text/html': '.html',
'text/xml': '.xml'}
See also
The default content type (MIME type) that is used for */*.
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: |
The decorator that registers function into before_request_funcs.
The decorator that registers function into after_request_funcs.
The decorator that registers a function into error_handlers.
@errorhandler(404)
def not_found(error):
return 'This page does not exist', 404
| Parameters: | code (int) – an error status code to associate |
|---|
See also
Decorator Method flask.Flask.errorhandler()
A decorator that is used to register custom template filter. You can specify a name for the filter, otherwise the function name will be used. Example:
@template_filter
def reverse(s):
return s[::-1]
@template_filter('order_by')
def query_order_by(query, column):
return query.order_by(column)
| Parameters: | name (basestring) – the optional name of the filter, otherwise the function name will be used |
|---|
Gets the available method for endpoint. It is useful for generating <form> tags.
<form action="{{ url_for('endpoint') }}"
method="{{ method_for('endpoint') }}">
| Parameters: | endpoint (basestring) – an endpoint name to find the available method |
|---|---|
| Returns: | an available method |
| Return type: | basestring |
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
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
Sets the g.session and g.database_engine global variables before every request.
Orders a query by column.
{% for post in user.posts|order_by('-created_at') %}
- {{ post }}
{% endfor %}
| Parameters: | column (basestring) – a column name. if - character has prepended, it becomes descending |
|---|---|
| Returns: | an ordered query |
| Return type: | sqlalchemy.orm.query.Query |