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.
Source Distribution
Built Distribution
File details
Details for the file flask_tryton-0.11.1.tar.gz
.
File metadata
- Download URL: flask_tryton-0.11.1.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 385a7479e4bde0003799f0b27c96adfb7bcd2f1a4f8998dc96368c6b5e2808f9 |
|
MD5 | c37c09cc89a06a1cbc45fd3aaf0eb992 |
|
BLAKE2b-256 | 315be02a7aee4f424725cecfe613c9b135e370903c5b7825afd29641c654b307 |
File details
Details for the file flask_tryton-0.11.1-py3-none-any.whl
.
File metadata
- Download URL: flask_tryton-0.11.1-py3-none-any.whl
- Upload date:
- Size: 17.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a156de197cac261b5c5b704b4c77b54089138b6483481c0f654880d9c9fb989 |
|
MD5 | 3ecf7a40baa9fd68ced50b8c89ad1dc4 |
|
BLAKE2b-256 | 6e4821a487762d7e2792511d6fa668e5235b7d2c59ed7228a156461a7b10e232 |