2014-06-04 10:11 GMT+02:00 Cédric Krier <[email protected]>:
> On 04 Jun 09:51, Raimon Esteve wrote:
> > 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)
>
> Why would you want to start more than 1 transaction?
>
First time I understand each decorator call a "independent" transaction
(new transaction each method)
I continue working about context processor and blueprints....
*tryton.py*
from flask import current_app
from flask_tryton import Tryton
tryton = Tryton(current_app)
Now I get message "RuntimeError: working outside of application context"
because I init tryton outsite app. I try "with current_app.app_context()"
and not expect good results.. If I change some parts "Flask tryton" to init
without app, I get successfull result.
Any ideas? I continue investigating....
*app.py*
from tryton import tryton
@app.context_processor
def cms_processor():
def menu(code=None):
Menu = tryton.pool.get('cms.menu')
print "call search tryton
return dict(cms_menu=menu)
*tryton.py*
from flask import current_app
from flask_tryton import Tryton
tryton = Tryton()
*blueprint.py*
from flask import Blueprint, current_app
from galatea.tryton import tryton
cms = Blueprint('cms', __name__, template_folder='templates')
@cms.route("/<slug>", endpoint="article")
@tryton.transaction()
def article(lang, slug):
Article = tryton.pool.get('cms.article')
print "call search tryton model"