LEFT | RIGHT |
(no file at all) | |
| 1 Flask-Tryton |
| 2 ============ |
| 3 |
| 4 Adds Tryton support to Flask application. |
| 5 |
| 6 By default transactions are readonly except for PUT, POST, DELETE and PATCH |
| 7 request methods. |
| 8 |
| 9 Nutshell |
| 10 -------- |
| 11 |
| 12 >>> from flask import Flask |
| 13 >>> from flask_tryton import Tryton |
| 14 |
| 15 >>> app = Flask(__name__) |
| 16 >>> app.config['TRYTON_DATABASE'] = 'test' |
| 17 >>> tryton = Tryton(app) |
| 18 >>> User = tryton.pool.get('res.user') |
| 19 |
| 20 >>> @tryton.default_context |
| 21 ... def default_context(): |
| 22 ... return User.get_preferences(context_only=True) |
| 23 |
| 24 >>> @app.route('/') |
| 25 ... @tryton.transaction() |
| 26 ... def hello(): |
| 27 ... user, = User.search([('login', '=', 'admin')]) |
| 28 ... return '%s, Hello World!' % user.name |
| 29 |
| 30 >>> app.run() |
| 31 |
| 32 For more information please visit the `flask_tryton website`_. |
| 33 |
| 34 .. _flask_tryton website: http://code.google.com/p/flask-tryton/ |
LEFT | RIGHT |