Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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))
Ejemplo n.º 5
0
 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))