<s> from smisk . mvc import * <EOL> from smisk . ipc . bsddb import shared_dict <EOL> from smisk . config import config <EOL> class root ( Controller ) : <EOL> def __init__ ( self ) : <EOL> self . entries = shared_dict ( persistent = config . get ( '<STR_LIT>' ) ) <EOL> def __call__ ( self ) : <EOL> pass <EOL> @ expose ( methods = '<STR_LIT:GET>' ) <EOL> def entry ( self ) : <EOL> '''<STR_LIT>''' <EOL> return { '<STR_LIT>' : self . entries . keys ( ) } <EOL> @ expose ( methods = ( '<STR_LIT:POST>' , '<STR_LIT>' ) ) <EOL> def set ( self , key , value ) : <EOL> '''<STR_LIT>''' <EOL> self . entries [ key . encode ( '<STR_LIT:utf-8>' ) ] = value <EOL> @ expose ( methods = '<STR_LIT:GET>' ) <EOL> def get ( self , key ) : <EOL> '''<STR_LIT>''' <EOL> try : <EOL> return { '<STR_LIT:value>' : self . entries [ key . encode ( '<STR_LIT:utf-8>' ) ] } <EOL> except KeyError : <EOL> raise http . NotFound ( '<STR_LIT>' % key ) <EOL> @ expose ( methods = '<STR_LIT>' ) <EOL> def delete ( self , key ) : <EOL> '''<STR_LIT>''' <EOL> utf8_key = key . encode ( '<STR_LIT:utf-8>' ) <EOL> if utf8_key not in self . entries : <EOL> raise http . NotFound ( u'<STR_LIT>' % key ) <EOL> del self . entries [ utf8_key ] <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( config = '<STR_LIT>' ) </s>
