How does this apply when there is no request? I'm not following you. Bill
On Thu, Apr 15, 2010 at 4:20 AM, Thomas Guettler <h...@tbz-pariv.de> wrote: > Hi, > > here is the way I do it: I use the TransactionMiddleware. Every request gets > commited or rollbacked (A of ACID (atomar)). > > Only methods that are called from the shell (scripts in bin/...) have the > commit_on_success decorator. > > If methods get used from the shell and from views, they do not use the > commit_on_success > decorator. Only the calling script in bin/ uses this. > > I would not use django.db.transaction.rollback() or something. Use the > available decorators. Maybe you need to restructure your code to > put the statements which can fail into an new decorated method. > > HTH, > Thomas > > Bill Freeman wrote: >> I'm running code from the manage.py shell to load stuff (from an XML export >> from >> an excel read of a SQL Server dump, of all things), which gets a database >> error >> (Postgersql correctly noticing that a value is too long for a field, >> for instance) upon >> calling the save method of a model. I'd like to catch the exception, log >> about >> what instance failed, and continue. >> >> But now the db connection is within a transaction, which I assume needs to be >> rolled back, and the connection won't talk to me until I do so. >> >> The trouble is, I don't know how. Just calling >> django.db.transaction.rollback() >> doesn't work, and neither do several other guesses. >> >> I presume that the view decorators won't do it since this isn't a request >> coming through the middleware to a view function. >> >> Can someone tell me the appropriate incantations? >> >> Bill >> > > -- > Thomas Guettler, http://www.thomas-guettler.de/ > E-Mail: guettli (*) thomas-guettler + de > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@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. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.