Amazing work Christophe, congrats!
Lot's of new cool stuff being added to 1.6, looking forward to it.

Regarding the nested xact context managers, let's say something that I
don't like happened and I want to abort everything:

with xact(using=db1):
    with xact(using=db2):
        obj1 = Ob1.save(using=db1)
        obj2 = Obj2.save(using=db2)
        if not_cool:
            raise Rollback

I'll raise Rollback since this is the way to force a rollback, as described
in the README.
But, this will roll back only whatever happened in the inner context
manager, thus obj1 will still exist, right?

Is there a way to make the Rollback reach the outer xact?
You wrote in a previous email that an exception will abort both, so
something like this should be the solution? (I have not tested):

try:
    with xact(using=db1):
        with xact(using=db2):
            obj1 = Ob1.save(using=db1)
            obj2 = Obj2.save(using=db2)
            if not_cool:
                raise Exception
except Exception:
    return False
return True


Cheers,
Leandro


On 6 July 2013 16:44, Christophe Pettus <[email protected]> wrote:

>
> On Jul 6, 2013, at 8:58 PM, Leandro Boscariol wrote:
> > And also thanks for mentioning xact, I wasn't aware of that!
>
> Full disclosure: I wrote it. :)  In 1.6, the new atomic() decorator /
> context manager is the way to go, but xact() works fine for now!
>
> --
> -- Christophe Pettus
>    [email protected]
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/WJUIVH2abjo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to