Hello,

I'm working a Flask APP and use Flask Tryton to connect to Tryton (1)

I have blueprints and context processor to connect to Tryton

* Blueprint (2). Modular Application
* Context Processor: Functions in templates

I have some routes or views call Tryton with @tryton.transaction
Also I have in some context processor call Trytn with @tryton.transaction.

My problem is about I can't start two or more transaction. Second
transaction, self.user is not None and get assert error (4)

I don't find solution to use Blueprint and Context Processor working
together. Any ideas?

Example:

*app.py*

from flask import app
from flask_tryton import Tryton
...

@app.context_processor
def cms_processor():

    tryton = Tryton(app)

    @tryton.transaction()
    def menu(code):
        print "Call tryton model"
        return []

    return dict(cms_menu=menu)

*blueprint.py*

from flask import Blueprint, current_app
from flask_tryton import Tryton

cms = Blueprint('cms', __name__, template_folder='templates')

@cms.route("/<slug>", endpoint="article")
def article(lang, slug):
    tryton = Tryton(current_app)

    @tryton.transaction()
    def _get_article(slug):
        print "Call tryton model"
    return _get_article(slug)


(1) https://pypi.python.org/pypi/flask_tryton/0.1
(2) http://flask.pocoo.org/docs/blueprints/
(3) http://flask.pocoo.org/docs/api/#flask.Flask.context_processor
(4)
http://hg.tryton.org/trytond/file/ab543d925fe5/trytond/transaction.py#l76

-- 
Raimon Esteve

Reply via email to