* Fabien Castarède [2016-05-28 11:27 +0200]:
In a Pyramid web app that use SQLAlchemy I need to work also with a Tryton
DB. With Tryton 3.8 I had implemented a Zope Data Manager for Tryton
backend that I joined to the current transaction of my Pyramid app. Now
with Tryton 4.0 it no longer works due to the new design of Tryton
transaction.

It's funny that you did since we use the design of the Zope Data
Manager to add the support of the two phase commit protocol to Tryton.

Here's an example of a data manager to send emails:
        http://hg.tryton.org/trytond/file/tip/trytond/sendmail.py

Basically what you have to do once you have created your datamanager
is to join it to the Tryton transaction (line 22). Afterwards, the
Tryton transaction should take care of everything for you.

In our case we decided that the Tryton transaction would be the one
orchestrating the others.

def _cleanup(request):
   TrytonTransaction().stop()
request.add_finished_callback(_cleanup)

I don't know how update my code to manage the new design of the Tryton
transaction. Especially how to stop transaction in the cleanup hook.

The Tryton Transactions are now context managers, the stop method has
been removed.

I don't know much about Pyramid so I don't know how you have to change
your code but you could use some inspiration from flask-tryton:

   http://hg.b2ck.com/flask-tryton/

--
Nicolas Évrard - B2CK SPRL
E-mail/Jabber: nicolas.evr...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

--
You received this message because you are subscribed to the Google Groups 
"tryton-dev" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton-dev/20160528095035.GA4127%40localhost.localdomain.

Reply via email to