It seems that we have to mention both the calls (commit & rollback) for
every @transaction.commit_manually decorator. One single function call won't
be sufficient to perform the operation.

On Tue, Aug 18, 2009 at 11:08 PM, Lokesh <lokeshmarema...@gmail.com> wrote:

>
> Hi,
>
> Verified the flow of statements for the posted code. Still the problem
> exists.
>
> Code works fine when I handled the transactions in general functions
> but not with the views.
>
> Could someone please clarify me on these
>
> 1. Can I use the transaction decorators(@transaction.commit_manually)
> for the views?
> 2. Do I need to do any further settings in settings file before using
> the transactions?
> 3. As per the Doc link "http://docs.djangoproject.com/en/dev/topics/db/
> transactions/#topics-db-transactions<http://docs.djangoproject.com/en/dev/topics/db/%0Atransactions/#topics-db-transactions>"
> we can use the transaction
> decorators in views but, I am not able to achieve the output . Please
> correct me if I missing anything.
>
> Thanks for your time.
>
> Regards,
> Lokesh
>
> On Aug 18, 8:07 pm, TiNo <tin...@gmail.com> wrote:
> > On Tue, Aug 18, 2009 at 16:19, Lokesh <lokeshmarema...@gmail.com> wrote:
> >
> > > Hi,
> >
> > > Unable to perform rollback the transactions. Ended up with the
> > > following error
> > > "Transaction managed block ended with pending COMMIT/ROLLBACK"
> >
> > > Can I rollback the db changes even if the code doesn't raise any
> > > excceptions?
> >
> > > Here is the code:
> > > from django.db import transaction
> > > @transaction.commit_manually
> > > def view(request):
> > >    if request.method== "POST" :
> > >        print "in post"
> > >        new_user = User.objects.create_user(username="testing",
> > > email="l...@lokesh.com", password="lokesh")
> > >        print "return value new user = %s" % new_user
> > >        transaction.rollback()
> > >        return render_to_response("templates/listuser.html",
> > >                                      context_instance=RequestContext
> > > (request))
> > >    else:
> > >        print "in else"
> > >        return render_to_response("templates/listu.html",
> > >                                  context_instance=RequestContext
> > > (request))
> >
> > You probably get this message when you are in the else block. There your
> > method ends without a commit() or rollback(), so django complains :D
> >
>


-- 
Thanks & Regards,
Lokesh.
lokeshmarema...@gmail.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to