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
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
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.