<s> from . logger import Log <EOL> from . config import Config <EOL> class Session ( object ) : <EOL> def __init__ ( self , session = None ) : <EOL> self . session = session <EOL> def __getattr__ ( self , name ) : <EOL> return getattr ( self . session , name ) <EOL> def __getitem__ ( self , key ) : <EOL> return self . session . get ( key , None ) <EOL> def __setitem__ ( self , key , value ) : <EOL> self . session . set ( key , value ) <EOL> def __delitem__ ( self , key ) : <EOL> self . session . delete ( key ) <EOL> def __iter__ ( self ) : <EOL> return self . session . __iter__ ( ) <EOL> def __contains__ ( self , name ) : <EOL> return self . session . __contains__ ( name ) <EOL> def __str__ ( self ) : <EOL> return self . session . __str__ ( ) <EOL> class SessionAbstract ( object ) : <EOL> one_day = <NUM_LIT> * <NUM_LIT> * <NUM_LIT> <EOL> def __init__ ( self ) : <EOL> self . log = Log . get_instance ( ) <EOL> self . config = Config ( ) <EOL> self . name = '<STR_LIT>' <EOL> self . lifetime = <NUM_LIT:0> <EOL> if '<STR_LIT>' in self . config : <EOL> self . name = self . config . session . get ( '<STR_LIT:name>' , self . name ) <EOL> self . lifetime = self . config . session . get ( '<STR_LIT>' , self . lifetime ) <EOL> self . path = '<STR_LIT:/>' <EOL> self . domain = None <EOL> self . secure = False <EOL> self . httponly = False <EOL> if '<STR_LIT>' in self . config : <EOL> self . path = self . config . cookie . get ( '<STR_LIT:path>' , self . path ) <EOL> self . domain = self . config . cookie . get ( '<STR_LIT>' , self . domain ) <EOL> self . secure = self . config . cookie . get ( '<STR_LIT>' , self . secure ) <EOL> self . httponly = self . config . cookie . get ( '<STR_LIT>' , self . httponly ) <EOL> self . data = { } <EOL> def write ( self ) : <EOL> raise NotImplementedError ( "<STR_LIT>" ) <EOL> def read ( self ) : <EOL> raise NotImplementedError ( "<STR_LIT>" ) <EOL> def get ( self , key , default = None ) : <EOL> return self . data . get ( key , default ) <EOL> def get_once ( self , key , default = None ) : <EOL> value = self . data . get ( key , default ) <EOL> self . delete ( key ) <EOL> return value <EOL> def has ( self , key ) : <EOL> return key in self . data <EOL> def set ( self , key , value ) : <EOL> self . data [ key ] = value <EOL> def delete ( self , key ) : <EOL> try : <EOL> del ( self . data [ key ] ) <EOL> return True <EOL> except : <EOL> return False <EOL> def clear ( self ) : <EOL> self . data = { } <EOL> def __getitem__ ( self , key ) : <EOL> return self . data . get ( key , None ) <EOL> def __setitem__ ( self , key , value ) : <EOL> self . data [ key ] = value <EOL> def __delitem__ ( self , key ) : <EOL> try : <EOL> del ( self . data [ key ] ) <EOL> except : <EOL> pass <EOL> def __iter__ ( self ) : <EOL> return self . data . __iter__ ( ) <EOL> def __contains__ ( self , name ) : <EOL> return name in self . data <EOL> def __str__ ( self ) : <EOL> return self . data . __str__ ( ) </s>
