def work(self): ''' Вызываемый по таймеру метод ''' currentTime = TimeManager.getTime() deleteInterval = ConfigurationManager.sessionDeleteInterval() time = currentTime + deleteInterval Session.objects.filter(referenceTime__lt = time).delete() self.test = self.test + 1
def getUser(sessionId): ''' Метод для получения user по sessionId ''' user = None #userId = 0 - SessionManager.checkSessionWorker.test if SessionManager.checkSession(sessionId): reqSession = Session.objects.get(pk = sessionId) reqSession.referenceTime = TimeManager.getTime() reqSession.save() user = reqSession.userId return user
def createSession(user): ''' Метод для создания сессии для пользователя ''' sessionId = -1 try: newSession = Session(userId = user, referenceTime = TimeManager.getTime()) newSession.save() sessionId = newSession.pk except: sessionId = -1 return sessionId