old_contents: from re import compile
  
  from django.core.urlresolvers import reverse
  from django.http import HttpResponseRedirect
  from django.conf import settings
  
  LOGIN_URL = reverse("login").lstrip('/')
  if hasattr(settings, 'LOGIN_REQUIRED_URLS') and isinstance(settings.LOGIN_REQUIRED_URLS, (list, tuple)):
      LOGIN_REQUIRED_URLS = [compile(expr) for expr in settings.LOGIN_REQUIRED_URLS]
  elif hasattr(settings, 'LOGIN_REQUIRED_URLS'):
      LOGIN_REQUIRED_URLS = [compile(settings.LOGIN_REQUIRED_URLS)]
  
  
  class LoginRequiredMiddleware:
      """
      Middleware that requires a user to be authenticated to view any page other
      than LOGIN_URL. Exemptions to this requirement can optionally be specified
      in settings via a list of regular expressions in LOGIN_EXEMPT_URLS (which
      you can copy from your urls.py).
  
      Requires authentication middleware and template context processors to be
      loaded. You'll get an error if they aren't.
      """
      def process_request(self, request):
          assert hasattr(request, 'user'), "The Login Required middleware\
   requires authentication middleware to be installed. Edit your\
   MIDDLEWARE_CLASSES setting to insert\
   'django.contrib.auth.middlware.AuthenticationMiddleware'. If that doesn't\
   work, ensure your TEMPLATE_CONTEXT_PROCESSORS setting includes\
   'django.core.context_processors.auth'."
          if not request.user.is_authenticated():
              path = request.path_info.lstrip('/')
              if path != LOGIN_URL:
                  for m in LOGIN_REQUIRED_URLS:
                      if m.match(path):
                          return HttpResponseRedirect('{0}?next={1}'.format(reverse("login"), request.path))
  
  class LoadUserMiddleware:
      """
      """
      def process_request(self, request):
          request.fmsuser = request.user.fmsuser
  
new_contents: from re import compile
  
  from django.core.urlresolvers import reverse
  from django.http import HttpResponseRedirect
  from django.conf import settings
  
  LOGIN_URL = reverse("login").lstrip('/')
  if hasattr(settings, 'LOGIN_REQUIRED_URLS') and isinstance(settings.LOGIN_REQUIRED_URLS, (list, tuple)):
      LOGIN_REQUIRED_URLS = [compile(expr) for expr in settings.LOGIN_REQUIRED_URLS]
  elif hasattr(settings, 'LOGIN_REQUIRED_URLS'):
      LOGIN_REQUIRED_URLS = [compile(settings.LOGIN_REQUIRED_URLS)]
  
  
  class LoginRequiredMiddleware:
      """
      Middleware that requires a user to be authenticated to view any page other
      than LOGIN_URL. Exemptions to this requirement can optionally be specified
      in settings via a list of regular expressions in LOGIN_EXEMPT_URLS (which
      you can copy from your urls.py).
  
      Requires authentication middleware and template context processors to be
      loaded. You'll get an error if they aren't.
      """
      def process_request(self, request):
          assert hasattr(request, 'user'), "The Login Required middleware\
   requires authentication middleware to be installed. Edit your\
   MIDDLEWARE_CLASSES setting to insert\
   'django.contrib.auth.middlware.AuthenticationMiddleware'. If that doesn't\
   work, ensure your TEMPLATE_CONTEXT_PROCESSORS setting includes\
   'django.core.context_processors.auth'."
          if not request.user.is_authenticated():
              path = request.path_info.lstrip('/')
              if path != LOGIN_URL:
                  for m in LOGIN_REQUIRED_URLS:
                      if m.match(path):
                          return HttpResponseRedirect('{0}?next={1}'.format(reverse("login"), request.path))
  
  class LoadUserMiddleware:
      """
      """
      def process_request(self, request):
          if request.user.is_authenticated():
              request.fmsuser = request.user.fmsuser
  
subject: fix unlogged middleware