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

Uploaded Source

Built Distribution

flask_tryton-0.9.2-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flask_tryton-0.9.2.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.1.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.7

File hashes

Hashes for flask_tryton-0.9.2.tar.gz
Algorithm Hash digest
SHA256 00ea9fb5f2336bd803df46e36200b1d3c610f5d20488220570113b06dbc28a2d
MD5 fe7afc2e7af192d1aabc9c28489a0e28
BLAKE2b-256 c1e5e89fcb5f33ceff0563dfc5c69ca692c5e7f36a210c2bfae922a6f0947f74

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flask_tryton-0.9.2-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.1.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.7

File hashes

Hashes for flask_tryton-0.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2fc0cafc1c1532f20fe56229c7cfb532dfd4e6d3a526761a04de23a899915502
MD5 7b6092ebfc4387fb879d4987c44942bc
BLAKE2b-256 844b26fffac0b2c201c9a16345a9f30d17f20782605a83357010242cfbd0cff0

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