Hi,
I was trying to make a flask app that send info to tryton using flask_tryton.
The code is the follow:
from flask import render_template, flash, redirect, url_for, session
from app import app
from app import tryton
Party = tryton.pool.get('party.party')
@tryton.default_context
def default_context():
return User.get_preferences(context_only=True)
@app.route('/', methods=['GET', 'POST'])
@tryton.transaction(readonly=False)
def index():
form = LoginForm()
if form.validate_on_submit():
firstname = form.firstname.data
party, = Party.create([{
'name': firstname,
}])
I have already setting these variables:
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.
But when I send the info I receive this error:
File "/testlib/python3.5/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/testlib/python3.5/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/testlib/python3.5/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/testlib/python3.5/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/testlib/python3.5/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/testlib/python3.5/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/testlib/python3.5/site-packages/flask_tryton.py", line 97, in wrapper
with Transaction().start(database, 0):
File "/testlib/python3.5/site-packages/trytond/transaction.py", line 96, in start
autocommit=autocommit)
File "/testlib/python3.5/site-packages/trytond/backend/postgresql/database.py", line 158, in get_connection
conn.set_isolation_level(ISOLATION_LEVEL_REPEATABLE_READ)
File "/testlib/python3.5/site-packages/psycopg2cffi/_impl/connection.py", line 84, in check_async_
return func(self, *args, **kwargs)
File "/testlib/python3.5/site-packages/psycopg2cffi/_impl/connection.py", line 273, in set_isolation_level
prev = self.isolation_level
File "/testlib/python3.5/site-packages/psycopg2cffi/_impl/connection.py", line 43, in check_closed_
return func(self, *args, **kwargs)
File "/testlib/python3.5/site-packages/psycopg2cffi/_impl/connection.py", line 265, in isolation_level
name = self._get_guc('default_transaction_isolation')
File "/testlib/python3.5/site-packages/psycopg2cffi/_impl/connection.py", line 234, in _get_guc
raise exceptions.OperationalError("can't fetch %s" % name)
psycopg2cffi._impl.exceptions.OperationalError: can't fetch default_transaction_isolation
I’m not sure what thing I miss something but I based the code in flask-tryton · PyPI
Thanks in advance!