There have been some questions in the past about how to catch 
IntegrityError(s) thrown by Model.save(), and there were two options 
suggested:

1). Don't wrap Model.save() in a try/except, because the data should be 
valid before saving.

I validate the data before saving, but if validation occurs at time t1 
and the save occurs at time t2 another request could've updated the db 
between t1 and t2. So it doesn't seem too far fetched that an 
IntegrityError will pop up sooner or later. And when it does the user is 
going to be presented with a 500 server error page, so they loose all 
the data they entered and have no idea what actually went wrong.

2). Import the db error classes of your choice from the db module.

Doing this unnecessarily couples my project to a particular db module. I 
think all the standard errors in the Python DB API should be made 
available through django.db, just like DatabaseError is.


Am I just taking the wrong approach here or something? Considering how 
few questions I found regarding this it would appear that most people 
are either blissfully ignoring db errors or know something I don't :)


-+ enlight +-

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to