<s> """<STR_LIT>""" <EOL> import gettext <EOL> import pylons <EOL> from pylons . configuration import request_defaults , response_defaults <EOL> from pylons . controllers . util import Request , Response <EOL> from pylons . util import ContextObj , PylonsContext <EOL> class ControllerWrap ( object ) : <EOL> def __init__ ( self , controller ) : <EOL> self . controller = controller <EOL> def __call__ ( self , environ , start_response ) : <EOL> app = self . controller ( ) <EOL> app . start_response = None <EOL> return app ( environ , start_response ) <EOL> class SetupCacheGlobal ( object ) : <EOL> def __init__ ( self , app , environ , setup_g = True , setup_cache = False , <EOL> setup_session = False ) : <EOL> if setup_g : <EOL> g = type ( '<STR_LIT>' , ( object , ) , { } ) <EOL> g . message = '<STR_LIT>' <EOL> g . counter = <NUM_LIT:0> <EOL> g . pylons_config = type ( '<STR_LIT>' , ( object , ) , { } ) <EOL> g . pylons_config . app_conf = dict ( cache_enabled = '<STR_LIT:True>' ) <EOL> self . g = g <EOL> self . app = app <EOL> self . environ = environ <EOL> self . setup_cache = setup_cache <EOL> self . setup_session = setup_session <EOL> self . setup_g = setup_g <EOL> def __call__ ( self , environ , start_response ) : <EOL> registry = environ [ '<STR_LIT>' ] <EOL> py_obj = PylonsContext ( ) <EOL> environ_config = environ . setdefault ( '<STR_LIT>' , { } ) <EOL> if self . setup_cache : <EOL> py_obj . cache = environ [ '<STR_LIT>' ] <EOL> registry . register ( pylons . cache , environ [ '<STR_LIT>' ] ) <EOL> environ_config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if self . setup_session : <EOL> py_obj . session = environ [ '<STR_LIT>' ] <EOL> registry . register ( pylons . session , environ [ '<STR_LIT>' ] ) <EOL> environ_config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if self . setup_g : <EOL> py_obj . app_globals = self . g <EOL> registry . register ( pylons . app_globals , self . g ) <EOL> translator = gettext . NullTranslations ( ) <EOL> py_obj . translator = translator <EOL> registry . register ( pylons . translator , translator ) <EOL> req = Request ( environ , charset = request_defaults [ '<STR_LIT>' ] , <EOL> unicode_errors = request_defaults [ '<STR_LIT>' ] , <EOL> decode_param_names = request_defaults [ '<STR_LIT>' ] <EOL> ) <EOL> req . language = request_defaults [ '<STR_LIT>' ] <EOL> response = Response ( <EOL> content_type = response_defaults [ '<STR_LIT>' ] , <EOL> charset = response_defaults [ '<STR_LIT>' ] ) <EOL> response . headers . update ( response_defaults [ '<STR_LIT>' ] ) <EOL> environ . update ( self . environ ) <EOL> py_obj . config = pylons . config . _current_obj ( ) <EOL> py_obj . request = req <EOL> py_obj . response = response <EOL> py_obj . tmpl_context = ContextObj ( ) <EOL> environ [ '<STR_LIT>' ] = py_obj <EOL> registry . register ( pylons . request , req ) <EOL> registry . register ( pylons . response , response ) <EOL> if '<STR_LIT>' in environ : <EOL> registry . register ( pylons . url , environ [ '<STR_LIT>' ] ) <EOL> return self . app ( environ , start_response ) </s>
