Re: Handling IntegrityError on transaction middleware commit

2009-11-28 Thread Karen Tracey
On Fri, Nov 27, 2009 at 6:35 AM, Ryan  wrote:

> I realize that I should be validating my data before saving it, but
> I'll admit I don't guard against every eventuality.  My question is,
> should I be doing something in my code to prevent this kind of poor
> exception handling, or should I file a bug against django?  I would
> certainly prefer the whole server not to break when the transaction
> commit fails for whatever reason -- it should rollback the transaction
> and give a 500 error page.
>

I think there is already a ticket filed on this:

http://code.djangoproject.com/ticket/6094

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




Handling IntegrityError on transaction middleware commit

2009-11-27 Thread Ryan
I had an IntegrityError come up on transaction commit (using postgres)
today on a production site -- trying to insert an invalid foreign key
value (an admin deleted something she shouldn't have).  The problem
was that instead of emailing me the exception like usual, django
logged the exception to my apache (using mod_wsgi) error log and then
that apache process was semi-broken for about half and hour, refusing
to recognize session cookies or log anyone in, but also not throwing
up any exceptions either.

I realize that I should be validating my data before saving it, but
I'll admit I don't guard against every eventuality.  My question is,
should I be doing something in my code to prevent this kind of poor
exception handling, or should I file a bug against django?  I would
certainly prefer the whole server not to break when the transaction
commit fails for whatever reason -- it should rollback the transaction
and give a 500 error page.

Here's the middleware tuple from my settings.py:

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.transaction.TransactionMiddleware',
)

Any thoughts?  Thanks.

--

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.