<s> import logging <EOL> from google . appengine . api import users <EOL> from google . appengine . api import memcache <EOL> def key_for_view_function ( view_function , for_admin_user = None ) : <EOL> if for_admin_user is None : <EOL> for_admin_user = users . is_current_user_admin ( ) <EOL> return "<STR_LIT>" % ( for_admin_user , str ( view_function . __module__ ) , str ( view_function . __name__ ) ) <EOL> def key_for_request ( request , for_admin_user = None ) : <EOL> """<STR_LIT>""" <EOL> params_string = "<STR_LIT:None>" <EOL> if request . method == "<STR_LIT:GET>" or request . method == "<STR_LIT:POST>" : <EOL> params = [ ] <EOL> query = request . GET if request . method == "<STR_LIT:GET>" else request . POST <EOL> for k , v_list in query . iterlists ( ) : <EOL> for v in v_list : <EOL> params . append ( "<STR_LIT>" % ( str ( k ) , str ( v ) ) ) <EOL> params . sort ( ) <EOL> params_string = '<STR_LIT:->' . join ( params ) <EOL> if for_admin_user is None : <EOL> for_admin_user = users . is_current_user_admin ( ) <EOL> key = "<STR_LIT>" % ( for_admin_user , request . path , request . method , params_string ) <EOL> return key <EOL> def clear_for_view_function ( view_function ) : <EOL> memcache . delete ( key_for_view_function ( view_function , for_admin_user = False ) ) <EOL> memcache . delete ( key_for_view_function ( view_function , for_admin_user = True ) ) <EOL> def clear_for_request ( request ) : <EOL> memcache . delete ( key_for_request ( request , for_admin_user = False ) ) <EOL> memcache . delete ( key_for_request ( request , for_admin_user = True ) ) <EOL> def clear_app_gallery ( ) : <EOL> from . . views . app import gallery as _gallery <EOL> memcache . delete ( key_for_view_function ( _gallery , for_admin_user = False ) ) <EOL> memcache . delete ( key_for_view_function ( _gallery , for_admin_user = True ) ) <EOL> def clear_api_apps_all ( ) : <EOL> from . . views . api import api_apps_all as _api_apps_all <EOL> memcache . delete ( key_for_view_function ( _api_apps_all , for_admin_user = False ) ) <EOL> memcache . delete ( key_for_view_function ( _api_apps_all , for_admin_user = True ) ) <EOL> def clear_all_apps ( ) : <EOL> clear_app_gallery ( ) <EOL> clear_api_apps_all ( ) </s>
