hi all,

  I noticed that recently has been added InterityError as a common
exception
  for all db (django.db.IntegrityError), so I wanted to make my view
aware
  of that, but I'm uncertain on how to accomplish this.

  I added a snippet like this one, in a sort of generic view:

  if form.is_valid():
     # No errors -- this means we can save the data! except for db
problems
     try:
         new_object = form.save()
     except IntegrityError:
         new_object = None
         form.errors['db'] = "Integrity Error from the db"

     if new_object:
         if request.user.is_authenticated():
              ...

   if new_object is None it falls back to the branch of form error
   handling... this was what I wanted... really it raises:
   ProgrammingError, current transaction is aborted, commands ignored
until
   end of transaction block.

   What's  wrong and which should be a correct way to handle
IntegrityError?

   Thanks in advance

   sandro
   *:-)


--~--~---------~--~----~------------~-------~--~----~
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