On Wed, Oct 6, 2010 at 9:02 PM, Luke Plant <[email protected]> wrote: > On Wed, 2010-10-06 at 07:42 -0400, Karen Tracey wrote: >> On Wed, Oct 6, 2010 at 6:53 AM, Russell Keith-Magee >> <[email protected]> wrote: >> That approach works (as in - it doesn't raise errors), but it >> means >> that under Python 2.4, you lose any of the "extra" data. In >> particular, it means that >> * it's really hard to do anything interesting with the 4XX >> series errors, >> * the HTTP 500 error emails won't have any details about the >> request >> that caused them >> * the DB logging calls won't include any details about the >> SQL that >> was being logged. >> >> The first and last don't bother me particularly -- they are new >> features that come with Django's use of logging and if they are not >> available under 2.4 I think that would be OK. That middle one is a >> killer though. >> >> What about just not adding the logging feature for Python 2.4? Make >> the calls conditional on Python version and fall back to old behavior >> in the 2.4 case? Not an approach we've taken before (that I can >> recall), but if the 2.4 level just doesn't do what we need it seems >> like it might be a reasonable restriction. > > The attached patch is like my other one, but restores Django 1.2 > functionality for HTTP 500 errors under Python 2.4. In all other cases > the logging calls just drop the 'extra' parameter under Python 2.4, > making them not very useful, but perhaps they will serve as a 'teaser' > to encourage people to upgrade their Python version! This is the best > compromise I can think of so far. It would need some notes in the docs > on logging, and the FAQ question on Python 2.4 functionality.
For the record, I've just opened ticket #14406 to track this. I've also uploaded a patch that possibly gives us the best of both worlds. In an earlier post, I mentioned that it might be possible to use the exc_info to solve this problem. The patch I've uploaded is a variant of your (Luke's) first patch, and uses the stack frame contained in the exc_info to maintain a logging-based approach to 500 error emails, while retaining all the available information. I've added a note to the logging docs indicating that 'extra' context isn't available in Python 2.4. However, I think the current FAQ text on Python 2.4 support actually gives us enough cover that we don't have to backtrack and claim partial 2.4 support. Our current text is clear that newer versions of Python will often have better features -- in this case, useful contextual information during logging. With the version-specific alteration that I've made to the email handler, we retain the same level of core functionality in the handlers that we provide; it's up to the end user to pick a Python version that will give them useful logging tools if they need them. The patch I've uploaded works fine on Python 2.6 -- and it continues to work fine on 2.6 if you force it to take the legacy branch of the if statement, too. However, I don't have access to a machine that runs Python 2.4. I can't think of a reason why the stack frame would behave differently under 2.4, but I'd like to have that confirmed. Yours, Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
