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.11.0.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: flask_tryton-0.11.0.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.9

File hashes

Hashes for flask_tryton-0.11.0.tar.gz
Algorithm Hash digest
SHA256 bb31b743b1b503f5772cf6fadec2ee4249168423a3d9621811a6c7ff76b7ca9c
MD5 9b771413c157e896e1dcb820dd4f43d4
BLAKE2b-256 8b55ec4f872016a9bae313a0e7b6075e16a7326f7499ab390e5f6399bf9f2a2b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flask_tryton-0.11.0-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.9

File hashes

Hashes for flask_tryton-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe56e2a83c168c6d78c2c763dcb7b1184f7d62dc3ef35fb4b4eecf63685df26f
MD5 4f91d69f162c125eba26a622e5302b6b
BLAKE2b-256 edbc70f9621a0c2cda0e8bc970029e611ea244ecfe0d61eedb3cb63001ffbcc6

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