except HttpError, e: response = SerializedHttpResponse(e.content, status=e.status) response = self.emit(response, request=request, emitter=e.emitter) except (AssertionError, ValidationError), e: response = SerializedHttpResponse(unicode(e), status=status.HTTP_400_BAD_REQUEST) response = self.emit(response, request=request) except Exception, e: response = self.handle_exception(e, request=request) # Send errors on mail errors_mail(response, request) # Send finished signal api_request_finished.send(self, request=request, response=response, **resources) if self.api: self.api.request_finished.send(self, request=request, response=response, **resources) return response @classmethod def check_method_allowed(cls, method): """ Ensure the request HTTP method is permitted for this resource, raising a ResourceException if it is not. """ if not method in cls.callmap.keys(): raise HttpError('Unknown or unsupported method \'%s\'' % method, status=status.HTTP_501_NOT_IMPLEMENTED) if not method in cls.allowed_methods:
response = self.emit(response, request=request, emitter=e.emitter) except (AssertionError, ValidationError), e: response = SerializedHttpResponse( unicode(e), status=status.HTTP_400_BAD_REQUEST) response = self.emit(response, request=request) except Exception, e: response = self.handle_exception(e, request=request) # Send errors on mail errors_mail(response, request) # Send finished signal api_request_finished.send(self, request=request, response=response, **resources) if self.api: self.api.request_finished.send(self, request=request, response=response, **resources) return response @classmethod def check_method_allowed(cls, method): """ Ensure the request HTTP method is permitted for this resource, raising a ResourceException if it is not. """ if not method in cls.callmap.keys():
except HttpError, e: response = Response(e.message, status=e.status) except Exception, e: response = self.handle_exception(e) # Always add these headers response.headers['Allow'] = ', '.join(as_tuple(self.allowed_methods)) response.headers['Vary'] = 'Authenticate, Accept' # Serialize response emitter = JSONEmitter if method == 'OPTIONS' else None response = self.emit(request, response, emitter=emitter) # Send finished signal api_request_finished.send(self, request=self.request, response=response) return response def check_method_allowed(self, method): """ Ensure the request method is permitted for this resource, raising a ResourceException if it is not. """ if not method in self.callmap.keys(): raise HttpError('Unknown or unsupported method \'%s\'' % method, status=status.HTTP_501_NOT_IMPLEMENTED) if not method in self.allowed_methods: raise HttpError('Method \'%s\' not allowed on this resource.' % method, status=status.HTTP_405_METHOD_NOT_ALLOWED) @classmethod def get_resource_name(cls): if cls.model: