On 1/6/06, Adrian Holovaty <[EMAIL PROTECTED]> wrote:

On 1/6/06, Amit Upadhyay <[EMAIL PROTECTED]> wrote:
> What is the rigth way of catching IntegrityError, the traceback I get
> suggests using _mysql_exceptions.IntegrityError, which is
> wrong because it assumes mysql, as well as it goes against the general
> python guideline of not using "hidden" members of modules.

As Dody Suria Wijaya suggested, you should improve your view code to
validate that the user isn't duplicate. Don't rely on the database to
check things; when using Django, database constraints are just a final
safety layer -- not a high-level source of validation.

Umm, actually my problem has little to do with validation and more with making sure that I catch all reasonably possible exceptions and handle them appropriately. For example, any IntegrityError is a minor problem, will generate appropriate warning to the user and be done with it, but I want to distinguish this from problems related to failure in talking to the database itself for which I might want to mail my sysadmins, and at last resort I catch Exception [most likely a programming issue] which mails me about the issue for example.

Sorry for using misleading subject if it was.

--
Amit Upadhyay
Blog: http://www.rootshell.be/~upadhyay
+91-9867-359-701

Reply via email to