On Sun, Jun 7, 2009 at 7:44 PM, ChrisStoyles <cstoy...@gmail.com> wrote:
> > Hi All, > > I just wanted to quickly reach out to the group for ideas as to why I > cannot get this to work: > > @transaction.commit_manually > def some_view(request): > # some view logic goes here > > sid = transaction.savepoint() > le = models.LogEntry() > le.message = 'A test log message' > le.save() > transaction.savepoint_commit(sid) > > transaction.rollback() > > My database back end is Postgres 8.3 and the engine I am using is > postgresql_psycopg2. Any ideas as to why my LogEntry would not be > committed to the database? I am not getting any exceptions being > raised, the code executes as though it has all worked perfectly. > I've not played with savepoints but the behavior you describe matches what the docs say: http://docs.djangoproject.com/en/dev/topics/db/transactions/#savepoints Specifically, savepoint_commit updates the savepoint to include operations since the savepoint was created, but it does not actually commit operations at that point. After you have done a savepoint_commit, a savepoint_rollback for that savepoint will not roll back the operations you hae committed for the savepoint. However, an entire transaction rollback, which is what you call, will roll back the whole transaction, including your savepoint "committed" ones. As the doc describes it, savepoints are a tool to allow for finer-grained rollback. You appear to be trying to use them for finer-grained commit, which I don't think is what they are intended to provide. Karen --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---