def process_request(self, request):
        if not self._initialized or not self._storage_path:
            return
            
        user = None
        session = None
            
        try:
            from lib.sessions import FileSession
            
            cookie_name = 'session_id_%s' % settings.SPLUNK_WEB_PORT
            if cookie_name not in request.COOKIES:
                return
                
            splunkweb_cookie = request.COOKIES[cookie_name]
            
            session = FileSession(
                splunkweb_cookie,
                storage_path=self._storage_path,
                timeout=60,
                clean_freq=5
            )
            
            # Acquire the lock. If this fails, we assume that the lock is no
            # longer acquired, and thus does not need to be released. Any 
            # future use is protected by the try/finally which will release
            # the lock when it is complete.
            session.acquire_lock(read_lock=True)
            
            # DO NOT PUT ANYTHING HERE. ALL CODE SHOULD BE INSIDE THE TRY/FINALLY,
            # SO THAT WE CAN ENSURE THE SESSION LOCK GETS RELEASED.
            
            try:
                if 'sessionKey' in session:
                    session_key = "Splunk %s" % session['sessionKey']
                    username = None
                    
                    if 'user' in session and 'name' in session['user']:
                        username = session['user']['name']
                        
                    user = get_user(username, session_key)
                    if user:
                        request._cached_user = user
            finally:
                # If we failed to create a user, and we have a session,
                # then we need to delete the session.
                # The main reason is that if we don't have a user, it means
                # we are not authenticated. If we aren't authenticated, we'll
                # get redirected to Splunkweb's login page, which will just 
                # redirect us back if a sessionKey value exists (whether it
                # is valid or not). We then get into an infinite redirect loop,
                # as we'll just come back here.
                if not user:
                    session.delete()
                
                # Release the lock
                session.release_lock()
                
        except Exception, e:
            logger.exception(e)
            pass

# This Django request logger is an implementation of Splunkweb's logging 
# handler. Django's objects are different, but the resulting logs are meant
# to be the same as Splunkweb
dataset/ETHPy150Open splunk/splunk-webframework/server/splunkdj/middlewares.py/SplunkWebSessionMiddleware.process_request/original