I can safely say that the default configuration does not do any sort of
autocommit. I tried it out, and used exactly what you made in your sample
code. Without any sort of manual commit from me, the data was not being
saved to the database.

On Tue, Sep 7, 2010 at 1:49 PM, ozwyzard <[email protected]> wrote:

> Thanks for the response.  That (commit) is my suspicion as well.  So,
> I was wondering if there is any TG configuration that is driving
> this.  I'll try to dig and see if there are any debug settings to show
> sqlalchemy DB transactions.  If I am still stumped I will try and post
> to the sqlalchemy group (as you suggest).
>
> Thanks.
>
> On Sep 7, 1:26 am, Michael Pedersen <[email protected]> wrote:
> > This actually took me a little bit to spot. I can't give a definitive
> > answer, but I can provide some explanation.
> >
> > On your line in the try block where you say that "transaction.doom()
> works
> > if placed here before the query", that's where you give the real clue.
> > Somehow, in your setup, a commit is being done before that query gets
> > executed. Because of that, you are now in a new transaction when the
> child
> > routine raises its own exception. As you're in a new transaction, you no
> > longer can rollback the DBSession.add(urec) that was done.
> >
> > For this particular issue, I have to strongly recommend contacting the
> > SQLAlchemy group. Somehow, a commit is being done, and I'm not capable
> > (personally) of figuring out why. Since SQLAlchemy is doing the commit, I
> > have to recommend asking them for help debugging why the commit is
> > occurring.
> >
> >
> >
> > On Mon, Sep 6, 2010 at 8:32 PM, ozwyzard <[email protected]> wrote:
> > > Hello,
> >
> > > I attempted trial and error (and poked around some code), but am not
> > > able to figure out the intended method of doing transactions in a TG 2
> > > application.
> >
> > > import transaction
> >
> > > def parent():
> > >    try:
> > >        urec = User(name='test', ...)
> > >        DBSession.add(urec)
> > >        # transaction.doom() works if placed here before the query
> > >        newrec = DBSession.query(User).filter(User.name='test', ...
> > > blah)
> > >        child_routine_that_does_dependent_DB_ops()  # DB op works but
> > > routine raises an exception for TESTING
> > >    except Exception, e:
> > >        transaction.doom()  # Does not remove the urec record from DB
> >
> > > What is the correct method for doing transaction rollbacks?  Does the
> > > rollback not occur after a successful query?  Do I need to modify some
> > > config item?
> >
> > > (I tried setting DBSession.autoflush = False,
> > > transaction.manager.abort(), DBSession.rollback(), but none of these
> > > work).
> >
> > > Thanks!
> >
> > > --
> > > 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]<turbogears%[email protected]>
> <turbogears%[email protected]<turbogears%[email protected]>
> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/turbogears?hl=en.
> >
> > --
> > Michael J. Pedersen
> > My IM IDs: Jabber/[email protected], ICQ/103345809,
> AIM/pedermj022171
> >           Yahoo/pedermj2002, MSN/[email protected]
>
> --
> 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]<turbogears%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/turbogears?hl=en.
>
>


-- 
Michael J. Pedersen
My IM IDs: Jabber/[email protected], ICQ/103345809, AIM/pedermj022171
          Yahoo/pedermj2002, MSN/[email protected]

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