Esempio n. 1
0
 def _clean_old_sessions(self):
     duration = datetime.timedelta(seconds=Session.SESSION_EXPIRE_TIME)
     session_age = datetime.datetime.now() - duration
     query = _Session.all()
     query.filter('last_activity <', session_age)
     results = query.fetch(1000)
     for result in results:
         result.delete()
Esempio n. 2
0
 def _get_session(self):
     #Get the user's session from the datastore
     query = _Session.all()
     query.filter('sid', self.sid)
     if Session.CHECK_USER_AGENT:
         query.filter('ua', os.environ['HTTP_USER_AGENT'])
     if Session.CHECK_IP:
         query.filter('ip', os.environ['REMOTE_ADDR'])
     results = query.fetch(1)
     if len(results) is 0:
         return None
     else:
         sessionAge = datetime.datetime.now() - results[0].last_activity
         if sessionAge.seconds > Session.SESSION_EXPIRE_TIME:
             results[0].delete()
             return None
         return results[0]