hi alon,

On 12/02/2011 10:32 PM, alonn wrote:
> in my turbogears application I'm writing to an mssql db with
> DBSession.flush() - this is a cron initiated method
> but after the commiting is made (my guess is transaction commit
> somewhere behind tg2.1 curtains) the db table is locked to access from
> another file (the main file that uses that db.. ) until I kill the tg
> application.
> I read that I can use transaction.doom() but I think that would also
> rollback the session (which I don' t want to - I just want to close
> the session ) and I don't know how this would influence the whole
> application (would tg bring it back to live next time I use DBSession?
> etc)
> 
> I'll be glad to some help here

a transaction is being begun before your controller method is being invoked, for
every dbsession you have in your model.
if no exception occurs in your controller method, all these transactions are
being committed after your controller method ends.
you may dbsession.flush() at the point you want, disregarding the transaction
commit that will follow.
you may begin your controller method with transaction.doom() or .commit(), so
your code will not run in the transaction above. this will free your hands to
begin, doom (rollback) and commit wherever you choose.
> 
> 2.another small question  - how do I control when the db transaction
> is being commited? since I iterate through a list of object, and in
> each one using DBSession.flush but the actuall commiting occures only
> when the iterating is over , my guess is the transaction.commit() is
> somehow called and all the new objects are commited to the db. can I
> control when this commiting is made?
> 

hth,
alex

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en.

Reply via email to