def process_exception(self, request, exception): if not STRACKS_API: return ## do not log 404 exceptions, see issue #356 if isinstance(exception, django.http.Http404): return client.exception("Crash: %s" % exception)
def contact_handler(handler, request, action): handler.context['form'] = ContactForm() if handler.post: handler.context['form'] = form = ContactForm(request.POST) if form.is_valid(): sender = form.cleaned_data.get('sender', '') title = handler.instance.content().title message = form.cleaned_data.get('message', '') receiver = Configuration.config().mailto ip = get_client_ip(request) if not receiver: try: receiver = settings.ADMINS[0][1] except IndexError: error("No suitable receiver for contactform found", data=dict(sender=sender, title=title, message=message)) return handler.redirect(handler.instance.path or '/', error="Unfortunately, something went wrong") body = """\ Message from %(sender)s @ %(ip)s == %(message)s """ % dict(sender=sender, ip=ip, message=message) try: send_mail('Feedback from %s on "%s"' % (sender, title), body, sender, [receiver], fail_silently=False ) except (SMTPException, Exception): exception("failed to send form", data=dict(sender=sender, title=title, message=message)) return handler.redirect(handler.instance.path or '/', error="Unfortunately, something went wrong") ### Handle smtp issues! fail_silently=False return handler.redirect(handler.instance.path or '/', success="Your feedback has been sent") return render_to_response("wheelcms_simplecontact/contact.html", handler.context)
def __exit__(self, type, value, tb): if type is not None: exception("Crash: %s" % value) set_request(None) self.end()