Hello, I have a concern when using flask_tryton.
I have carried out all the steps as shown here. But I still get this error :
[2024-09-27 11:27:45,130] ERROR in app: Exception on /doctor/party [GET]
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib/python3/dist-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/lib/python3/dist-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3/dist-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/lib/python3/dist-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/python3/dist-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/gnuhealth/.local/lib/python3.8/site-packages/flask_tryton.py", line 143, in wrapper
tryton = current_app.extensions['Tryton']
KeyError: 'Tryton'
[details="Configuration and tests"]
from flask_tryton import Tryton
app = Flask(__name__)
app.config['TRYTON_CONFIG'] = '/home/gnuhealth/gnuhealth/tryton/server/config/trytond.conf'
app.config['TRYTON_DATABASE'] = 'PDMD_SANTE'
app.config['TRYTON_USER'] = 0
tryton = Tryton(app)
User = tryton.pool.get('res.user')
bp = Blueprint('doctors', __name__, url_prefix='/doctor/')
@tryton.default_context
def default_context():
return User.get_preferences(context_only=True)
@bp.route('/tests')
def tests():
return {'The Answer': "La réponses"}
@bp.route('/party')
@tryton.transaction()
def party():
user, = User.search([('login', '=', 'admin')])
print('Le username des Username -------- ', user)
return {"User": user.name}
[/details]