old_contents: """
  This middleware will handle marking users into certain groups and loading
  their ACLs into the request.
  """
  
  from access import acl
  from users.models import UserProfile
  
  
  class ACLMiddleware(object):
  
      def process_request(self, request):
          """
          Keep groups as part of the request.
          """
  
          # figure out our list of groups...
          if request.user.is_authenticated():
              amo_user = (UserProfile.objects.request_user()
                          .get(pk=request.user.pk))
              request.user._profile_cache = request.amo_user = amo_user
              request.groups = request.amo_user.groups.all()
  
              if acl.action_allowed(request, 'Admin', '%'):
                  request.user.is_staff = True
  
new_contents: """
  This middleware will handle marking users into certain groups and loading
  their ACLs into the request.
  """
  from functools import partial
  
  from access import acl
  from users.models import UserProfile
  
  
  class ACLMiddleware(object):
  
      def process_request(self, request):
          """Attach authentication/permission helpers to request."""
          request.check_ownership = partial(acl.check_ownership, request)
  
          # figure out our list of groups...
          if request.user.is_authenticated():
              amo_user = (UserProfile.objects.request_user()
                          .get(pk=request.user.pk))
              request.user._profile_cache = request.amo_user = amo_user
              request.groups = request.amo_user.groups.all()
  
              if acl.action_allowed(request, 'Admin', '%'):
                  request.user.is_staff = True
  
subject: attach acl.check_ownership to the request