<s> from . . compat import cPickle <EOL> class DummySession ( object ) : <EOL> def __init__ ( self , session_id , redis , timeout = <NUM_LIT> , <EOL> serialize = cPickle . dumps ) : <EOL> self . session_id = session_id <EOL> self . redis = redis <EOL> self . timeout = timeout <EOL> self . serialize = serialize <EOL> self . managed_dict = { } <EOL> self . created = float ( ) <EOL> def to_redis ( self ) : <EOL> return self . serialize ( { <EOL> '<STR_LIT>' : self . managed_dict , <EOL> '<STR_LIT>' : self . created , <EOL> '<STR_LIT>' : self . timeout , <EOL> } ) <EOL> class DummyRedis ( object ) : <EOL> def __init__ ( self , raise_watcherror = False , ** kw ) : <EOL> self . url = None <EOL> self . timeouts = { } <EOL> self . store = { } <EOL> self . pipeline = lambda : DummyPipeline ( self . store , raise_watcherror ) <EOL> self . __dict__ . update ( kw ) <EOL> @ classmethod <EOL> def from_url ( cls , url , ** opts ) : <EOL> redis = DummyRedis ( ) <EOL> redis . url = url <EOL> redis . opts = opts <EOL> return redis <EOL> def get ( self , key ) : <EOL> return self . store . get ( key ) <EOL> def set ( self , key , value ) : <EOL> self . store [ key ] = value <EOL> def delete ( self , * keys ) : <EOL> for key in keys : <EOL> del self . store [ key ] <EOL> def exists ( self , key ) : <EOL> return key in self . store <EOL> def expire ( self , key , timeout ) : <EOL> self . timeouts [ key ] = timeout <EOL> def ttl ( self , key ) : <EOL> return self . timeouts . get ( key ) <EOL> class DummyPipeline ( object ) : <EOL> def __init__ ( self , store , raise_watcherror = False ) : <EOL> self . store = store <EOL> self . raise_watcherror = raise_watcherror <EOL> def __enter__ ( self ) : <EOL> return self <EOL> def __exit__ ( self , * arg , ** kwarg ) : <EOL> pass <EOL> def multi ( self ) : <EOL> pass <EOL> def set ( self , key , value ) : <EOL> self . store [ key ] = value <EOL> def get ( self , key ) : <EOL> return self . store . get ( key ) <EOL> def expire ( self , key , timeout ) : <EOL> pass <EOL> def watch ( self , key ) : <EOL> if self . raise_watcherror : <EOL> from redis . exceptions import WatchError <EOL> raise WatchError <EOL> def execute ( self ) : <EOL> pass </s>
