Question about base_config.use_transaction_manager

17 views
Skip to first unread message

Rotem Tamir

unread,
Dec 3, 2011, 4:03:40 AM12/3/11
to TurboGears
Hi all,

I'm trying to figure out some mess on an application I'm building.

From reading the TG2.1 docs I thought I understood that as long as I
add SQLAlchemy objects to a DBSession, using DBSession.add, and
flushing the session when I'm done all of my transaction logic is
handled by TG middleware.

However now I came across this page in the docs:
http://www.turbogears.org/2.1/docs/main/Config/SQLAlchemy.html?highlight=use_transaction_manager

And read about this:
"TurboGears takes advantage of repoze’s transaction manager software.
Basically, the transaction manager wraps each of your controller
methods, and should a method fail, the transaction will roll back. if
you utilize the transaction manager, then the result of a successful
method call results in a commit to the database. If the contoller
method does not utilize the database, there is no database interaction
performed. What this means is that you never have to worry about
committing, or rolling back when controller code fails, TG handles
this for you automatically."

Which sounds great, however, I read that i was supposed to check
whether base_config.use_transaction_manager was set to true but
didn't find that setting at all in my config files. I added:
base_config.use_transaction_manager = True
to my app_cfg.py file.

Now I'm wondering, how can I check that this magic is working? How can
test that my transactions are being commited thru this mechanism
properly?

Rotem

Diez B. Roggisch

unread,
Dec 3, 2011, 5:42:44 AM12/3/11
to turbo...@googlegroups.com


The magic is already working if rows appear in the DB. I don't know about this config-option (looks like app_cfg.py-based), but there is already a TM at work, probably through repoze.tm2.

Diez

NiL

unread,
Dec 3, 2011, 5:09:01 PM12/3/11
to turbo...@googlegroups.com
hi,

I have experienced inconsistencies in this behaviour when my controller ends with a raise HTTP code 301

it seems that in this case neither rollback or commit are issued, developing 'idle in transaction' situation with postgres.

maybe I should dig the repoze.tm2 source base

NiL

Alessandro Molina

unread,
Dec 5, 2011, 6:02:02 AM12/5/11
to turbo...@googlegroups.com
use_transaction_manager is True by default in AppConfig class.

AppConfig.add_tm_middleware is used to set it up and
AppConfig.commit_veto is used to decide whenever a commit or a
rollback should be issued.

If things are not working as expected it might be due to a problem in
repoze.tm2 or commit_veto.

Let us know if you find any issue, we will try to fix it.

> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/turbogears/-/wXRpXYPmA2kJ.
>
> To post to this group, send email to turbo...@googlegroups.com.
> To unsubscribe from this group, send email to
> turbogears+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/turbogears?hl=en.

Reply all
Reply to author
Forward
0 new messages