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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: flask_tryton-0.9.3.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.8

File hashes

Hashes for flask_tryton-0.9.3.tar.gz
Algorithm Hash digest
SHA256 ece8fba2f6d7ed5fe85136ea4ea12e15c7f8435a47ffcad57fe203c4f5dc7fe0
MD5 95b220ae8a145ff7c369b7844cd486d5
BLAKE2b-256 1354f1021153f7190e83dcddc83427b7a9839b1cec1820dcdc7562e0767848db

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flask_tryton-0.9.3-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.8

File hashes

Hashes for flask_tryton-0.9.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2ce5d14305a5263481753190bb514f0e00e7d7face0a2cba4ef28016736e4eea
MD5 14cd775ddac5145706fe52e159a07011
BLAKE2b-256 91f3128db03d6947b8b883dd6c1d593ca5d1d10af3c6e6cdce5457c5b9853444

See more details on using hashes here.

Supported by

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