Did you try subclassing list (& overriding __iter__) for the ADMINS
object?

 -rob

On Oct 15, 1:58 pm, Jesse Young <[EMAIL PROTECTED]> wrote:
> The built-in behavior for
> django.core.handlers.base.handle_uncaught_exception calls mail_admins
> for each internal server error.
>
> So if a very high-traffic view has an internal server error, duplicate
> emails will be sent at a very high rate. This isn't usually
> desirable...
>
> We worked around this by changing mail_admins directly in our copy of
> Django to store the last time an email was sent on the filesystem and
> avoid sending multiple emails in too short of a time interval. But it
> seems like there should be a better way to customize this without
> having to modify Django.
>
> I suppose one could define a mail_admins replacement in our app and
> assign it to django.core.mail.mail_admins. But that's rather hacky...
>
> Also, BaseHandler says that handle_uncaught_exception can be
> overridden, but its derived classes ModPythonHandler and WSGIHandler
> are referenced directly in Django, so I don't really see how to
> subclass it without changing the Django code.
>
> I was thinking it would be useful to add a setting like
> EXCEPTION_NOTIFIER = 'path.to.custom.notifier' , where the default
> would look something like this:
>
> def mail_exception_to_admins(request, exc_info):
>         from django.core.mail import mail_admins
>         subject = 'Error (%s IP): %s' %
> ((request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS and
> 'internal' or 'EXTERNAL'), request.path)
>         try:
>             request_repr = repr(request)
>         except:
>             request_repr = "Request repr() unavailable"
>         message = "%s\n\n%s" % (self._get_traceback(exc_info),
> request_repr)
>         mail_admins(subject, message, fail_silently=True)
>
> Thoughts?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to