Files
tryton/trytond/session.py
T

25 lines
638 B
Python
Raw Normal View History

2009-02-11 14:52:22 +01:00
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
2009-08-27 14:38:52 +02:00
import os
import base64
2009-02-11 14:52:22 +01:00
import time
class Session(int):
2010-02-18 18:50:35 +01:00
def __init__(self, value):
2009-04-08 17:55:24 +02:00
super(Session, self).__init__()
2009-02-11 14:52:22 +01:00
self.__data = {
2009-08-27 14:38:52 +02:00
'session': base64.b64encode(os.urandom(32)),
2009-02-11 14:52:22 +01:00
'timestamp': time.time(),
2009-08-14 11:38:02 +02:00
'name': '',
2009-02-11 14:52:22 +01:00
}
def __getattr__(self, name):
return self.__data[name]
def __getitem__(self, name):
return self.__data[name]
def reset_timestamp(self):
self.__data['timestamp'] = time.time()