def process_request(self, request): if _request_creates_revision(request): context = create_revision_base(manage_manually=self.manage_manually, using=self.using) context.__enter__() _set_user_from_request(request) if not hasattr(request, "_revision_middleware"): setattr(request, "_revision_middleware", {}) request._revision_middleware[self] = context
def process_request(self, request): if _request_creates_revision(request): context = create_revision_base( manage_manually=self.manage_manually, using=self.using) context.__enter__() _set_user_from_request(request) if not hasattr(request, "_revision_middleware"): setattr(request, "_revision_middleware", {}) request._revision_middleware[self] = context
def do_revision_view(request, *args, **kwargs): if request_creates_revision(request): try: with create_revision_base(manage_manually=manage_manually, using=using, atomic=atomic): response = func(request, *args, **kwargs) # Check for an error response. if response.status_code >= 400: raise _RollBackRevisionView(response) # Otherwise, we're good. _set_user_from_request(request) # Additional call _add_meta(request) return response except _RollBackRevisionView as ex: return ex.response return func(request, *args, **kwargs)
def _close_revision(self, request, is_exception): if self in getattr(request, "_revision_middleware", {}): _set_user_from_request(request) request._revision_middleware.pop(self).__exit__( *sys.exc_info() if is_exception else (None, None, None))
def _close_revision(self, request, is_exception): if self in getattr(request, "_revision_middleware", {}): _set_user_from_request(request) request._revision_middleware.pop(self).__exit__(*sys.exc_info() if is_exception else (None, None, None))