On Oct 15, 10:18 pm, Jesse Young <[EMAIL PROTECTED]> wrote:
> Is your suggestion that, since mail_admins happens to be the only
> place in Django that uses settings.ADMINS, I could do something like:
>
> class AdminsObject(list):
> def __iter__(self):
> // do some custom notification
> // manually write the friendly 500 error page to the output
> stream somehow
> raise Exception // can't raise StopIteration here or mail_admins
> will connect to the SMTP server
> ADMINS = AdminsObject()
I was hoping it wouldn't be quite that ugly! And just had an empty
list.iter in mind. Something like:
class AdminsObject(list):
def __iter__(self):
if ok_to_send(): # enough time since last mail or whatever
return super(AdminsObject, self).__iter__()
return [].__iter__()
ADMINS = AdminsObject([
('Your Name', '[EMAIL PROTECTED]'),
])
I think your exception would propagate up to the
handle_uncaught_exception and the user would not see the "friendly
error message".
However, after seeing your comment regarding the exception I looked at
EmailMessage and was surprised to see that it attempts to send even
with an empty ADMINS list. It should return if not self.to and not
self.bcc, I think.
> That would be pretty hilarious. Not particularly straightforward or
> maintainable though.
Yes, the got_request_exception signal seems like a better solution as
it gives you more context.
-rob
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---