Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask_tryton-0.12.0.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

flask_tryton-0.12.0-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file flask_tryton-0.12.0.tar.gz.

File metadata

  • Download URL: flask_tryton-0.12.0.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for flask_tryton-0.12.0.tar.gz
Algorithm Hash digest
SHA256 5b7ca697a0416a965cd650b67cacf69f4f3d47b49ee969659520170e60caeec1
MD5 e593995730ab3264240d2b5f7200d80a
BLAKE2b-256 5be3d86423b1e7840036f624dd6c2759ef8906423a70a70d8197db2d91e89497

See more details on using hashes here.

File details

Details for the file flask_tryton-0.12.0-py3-none-any.whl.

File metadata

File hashes

Hashes for flask_tryton-0.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b7f32d1e2b6c8f01a1342c9ef405162684e6b8c04a24f90cbf3fe6be861ac9c
MD5 473eb5f497daf2e03d3cd7383109dc07
BLAKE2b-256 de5fd6425a038653ae40f6e43fc05d9751bae99c034c9fff4a020f877af11b2a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page