On Thu, Feb 26, 2009 at 9:22 AM, Sushant Sinha <sushant...@gmail.com> wrote:
> I agree with you that a user code can best determine whether to roll > back or commit. However, I think this is not reflected in the > documentation for the models at all. > > http://docs.djangoproject.com/en/dev/ref/models/instances/?from=olddocs > http://docs.djangoproject.com/en/dev/topics/db/models/#topics-db-models > > My understanding is that updates/insert/delete to database models are > handled as auto-commit transactions (each model query is itself a > transaction). However, in case of a failure, django gives me a bad state > of the database. And my rest of the code fails if I do not explicitly > handle the transaction commit/rollover. This seems really problematic > for the programmer. > > If a single query fails, then what does commit mean. Shouldn't we do > just rollover as commit has no meaning? > See this thread: http://groups.google.com/group/django-developers/browse_thread/thread/620ccff354c859c2/5bec41ee3271f30a ? for a long discussion of why Django's "autocommit-like" mode is the way it is. It's a subject I haven't followed in any great detail but I think the upshot is that when the ticket mentioned in that thread gets committed, you will be able to configure things to use "native" autocommit, in which case I expect you will not need to worry about commit or rollback after an error. At the moment, though, whenever your code catches a database-related exception, it does need to worry about cleaning up the transaction before attempting more database operations. 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 -~----------~----~----~----~------~----~------~--~---