def __repr__(self): kw = dict() if self.master_instance is not None: kw.update(master_instance=obj2str(self.master_instance)) if self.filter is not None: kw.update(filter=repr(self.filter)) if self.known_values: kw.update(known_values=self.known_values) if self.requesting_panel: kw.update(requesting_panel=self.requesting_panel) u = self.get_user() if u is not None: kw.update(user=u.username) if False: # self.request: kw.update(request=format_request(self.request)) return "<%s %s(%s)>" % (self.__class__.__name__, self.bound_action.full_name(), kw)
def __repr__(self): kw = dict() if self.master_instance is not None: kw.update(master_instance=obj2str(self.master_instance)) if self.filter is not None: kw.update(filter=repr(self.filter)) if self.known_values: kw.update(known_values=self.known_values) if self.requesting_panel: kw.update(requesting_panel=self.requesting_panel) u = self.get_user() if u is not None: kw.update(user=u.username) if False: # self.request: kw.update(request=format_request(self.request)) return "<%s %s(%s)>" % ( self.__class__.__name__, self.bound_action.full_name(), kw)
def process_exception(self, request, exception): if request.is_ajax(): (exc_type, exc_info, tb) = sys.exc_info() # response to client: response = "%s: " % exc_type.__name__ response += "%s" % exc_info if not isinstance(exception, self.no_traceback): # message to be logged: msg = "AjaxExceptionResponse {0}\n".format(response) msg += "\nin request {0}\n".format(format_request(request)) msg += "TRACEBACK:\n" for tb in traceback.format_tb(tb): msg += smart_text(tb) if settings.DEBUG: settings.SITE.logger.warning(msg) else: settings.SITE.logger.exception(msg) return HttpResponse(response, status=400)
def process_exception(self, request, exception): if request.is_ajax(): (exc_type, exc_info, tb) = sys.exc_info() # response to client: response = "%s: " % exc_type.__name__ response += "%s" % exc_info # message to be logged: msg = "AjaxExceptionResponse {0}\n".format(response) msg += "\nin request {0}\n".format(format_request(request)) msg += "TRACEBACK:\n" for tb in traceback.format_tb(tb): msg += smart_text(tb) if settings.DEBUG: settings.SITE.logger.warning(msg) else: settings.SITE.logger.exception(msg) if isinstance(exception, PermissionDenied): return HttpResponseForbidden(response) if isinstance(exception, ObjectDoesNotExist): return HttpResponseBadRequest(response) return HttpResponseServerError(response)