Adds Tryton support to Flask application
Project description
Adds Tryton support to Flask application.
By default transactions are readonly except for PUT, POST, DELETE and PATCH request methods. It provides also 2 routing converters record and records.
Setting the configure_jinja flag adds the following filters on jinja templates: numberformat, dateformat, currencyformat and timedeltaformat. The filters apply the same formatting as Tryton reports.
Nutshell
>>> from flask import Flask >>> from flask_tryton import Tryton >>> app = Flask(__name__) >>> app.config['TRYTON_DATABASE'] = 'test' >>> tryton = Tryton(app, configure_jinja=True) >>> User = tryton.pool.get('res.user') >>> @tryton.default_context ... def default_context(): ... return User.get_preferences(context_only=True) >>> @app.route('/') ... @tryton.transaction() ... def hello(): ... user, = User.search([('login', '=', 'admin')]) ... return '%s, Hello World!' % user.name >>> @app.route('/user/<record("res.user"):user>') ... @tryton.transaction() ... def user(user): ... return user.name >>> @app.route('/users/<records("res.user"):users>') ... @tryton.transaction() ... def users(users): ... return ', '.join(u.name for u in users) >>> app.run()
There are three configuration options available:
- TRYTON_DATABASE: the Tryton’s database to connect.
- TRYTON_USER: the Tryton user id to use, by default 0 (aka root).
- TRYTON_CONFIG: the optional path to the Tryton’s configuration.
To report issues please visit the flask_tryton bugtracker.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size flask_tryton-0.10.0-py3-none-any.whl (17.1 kB) | File type Wheel | Python version py3 | Upload date | Hashes View |
Filename, size flask_tryton-0.10.0.tar.gz (18.2 kB) | File type Source | Python version None | Upload date | Hashes View |
Close
Hashes for flask_tryton-0.10.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8ec86a5ff18e44f9056d066f854466f24f6c4832ca222db8830e3028d34ffaf |
|
MD5 | 4b315cb8d785382955211e99788899a4 |
|
BLAKE2-256 | a1770b078db0509e1f0837615a7c4d1a6f3ee1d98ec69ccaf18bcef4da35ffb8 |