def _setup_app_env(self, environ): """Setup Request, Response and TurboGears context objects. Is also in charge of pushing TurboGears context into the paste registry and detect test mode. Returns whenever the testmode is enabled or not and the TurboGears context. """ conf = self.config testing = False # Setup the basic global objects req = Request(environ) req._fast_setattr('_language', self.lang) req._fast_setattr('_response_type', None) resp_options = self.resp_options response = Response(content_type=resp_options['content_type'], charset=resp_options['charset'], headers=resp_options['headers']) # Setup the translator object translator = _get_translator(self.lang, tg_config=conf) if self.strict_tmpl_context: tmpl_context = TemplateContext() else: tmpl_context = AttribSafeTemplateContext() app_globals = self.globals locals = RequestLocals() locals.response = response locals.request = req locals.app_globals = app_globals locals.config = conf locals.tmpl_context = tmpl_context locals.translator = translator locals.session = environ.get( 'beaker.session') # Usually None, unless middleware in place locals.cache = environ.get( 'beaker.cache') # Usually None, unless middleware in place environ['tg.locals'] = locals # Register Global objects registry = environ['paste.registry'] registry.register(request_local.config, conf) registry.register(request_local.context, locals) if 'paste.testing_variables' in environ: testing = True testenv = environ['paste.testing_variables'] testenv['req'] = req testenv['response'] = response testenv['tmpl_context'] = tmpl_context testenv['app_globals'] = self.globals testenv['config'] = conf testenv['session'] = locals.session testenv['cache'] = locals.cache return testing, locals, registry
def setup_app_env(self, environ): """Setup Request, Response and TurboGears context objects. Is also in charge of pushing TurboGears context into the paste registry and detect test mode. Returns whenever the testmode is enabled or not and the TurboGears context. """ conf = self.config # Setup the basic global objects req = Request(environ) req._fast_setattr('_language', conf['lang']) req._fast_setattr('_response_type', None) resp_options = self.resp_options response = Response(content_type=resp_options['content_type'], charset=resp_options['charset'], headers=resp_options['headers']) # Setup the translator object lang = conf['lang'] translator = _get_translator(lang, tg_config=conf) if self.strict_tmpl_context: tmpl_context = ContextObj() else: tmpl_context = AttribSafeContextObj() app_globals = self.globals session = environ.get('beaker.session') cache = environ.get('beaker.cache') locals = RequestLocals() locals.response = response locals.request = req locals.app_globals = app_globals locals.config = conf locals.tmpl_context = tmpl_context locals.translator = translator locals.session = session locals.cache = cache if self.enable_routes: #pragma: no cover url = environ.get('routes.url') locals.url = url environ['tg.locals'] = locals #Register Global objects registry = environ['paste.registry'] registry.register(request_local.config, conf) registry.register(request_local.context, locals) if 'paste.testing_variables' in environ: testenv = environ['paste.testing_variables'] testenv['req'] = req testenv['response'] = response testenv['tmpl_context'] = tmpl_context testenv['app_globals'] = self.globals testenv['config'] = conf testenv['session'] = locals.session testenv['cache'] = locals.cache return True, locals return False, locals
def setup_app_env(self, environ, start_response): """Setup and register all the Pylons objects with the registry After creating all the global objects for use in the request, :meth:`~PylonsApp.register_globals` is called to register them in the environment. """ conf = self.config # Setup the basic global objects req = Request(environ) req._fast_setattr('_language', conf['lang']) req._fast_setattr('_response_type', None) resp_options = self.resp_options response = Response( content_type=resp_options['content_type'], charset=resp_options['charset'], headers=resp_options['headers']) # Setup the translator object lang = conf['lang'] translator = _get_translator(lang, tg_config=conf) if self.strict_tmpl_context: tmpl_context = ContextObj() else: tmpl_context = AttribSafeContextObj() app_globals = self.globals session = environ.get('beaker.session') cache = environ.get('beaker.cache') locals = RequestLocals() locals.response = response locals.request = req locals.app_globals = app_globals locals.config = conf locals.tmpl_context = tmpl_context locals.translator = translator locals.session = session locals.cache = cache if self.enable_routes: #pragma: no cover url = environ.get('routes.url') locals.url = url environ['tg.locals'] = locals #Register Global objects registry = environ['paste.registry'] registry.register(request_local.config, conf) registry.register(request_local.context, locals) if 'paste.testing_variables' in environ: testenv = environ['paste.testing_variables'] testenv['req'] = req testenv['response'] = response testenv['tmpl_context'] = tmpl_context testenv['app_globals'] = self.globals testenv['config'] = conf testenv['session'] = locals.session testenv['cache'] = locals.cache return True return False
def setup_app_env(self, environ): """Setup Request, Response and TurboGears context objects. Is also in charge of pushing TurboGears context into the paste registry and detect test mode. Returns whenever the testmode is enabled or not and the TurboGears context. """ conf = self.config # Setup the basic global objects req = Request(environ) req._fast_setattr('_language', conf['lang']) req._fast_setattr('_response_type', None) resp_options = self.resp_options response = Response( content_type=resp_options['content_type'], charset=resp_options['charset'], headers=resp_options['headers']) # Setup the translator object lang = conf['lang'] translator = _get_translator(lang, tg_config=conf) if self.strict_tmpl_context: tmpl_context = ContextObj() else: tmpl_context = AttribSafeContextObj() app_globals = self.globals session = environ.get('beaker.session') cache = environ.get('beaker.cache') locals = RequestLocals() locals.response = response locals.request = req locals.app_globals = app_globals locals.config = conf locals.tmpl_context = tmpl_context locals.translator = translator locals.session = session locals.cache = cache if self.enable_routes: #pragma: no cover url = environ.get('routes.url') locals.url = url environ['tg.locals'] = locals #Register Global objects registry = environ['paste.registry'] registry.register(request_local.config, conf) registry.register(request_local.context, locals) if 'paste.testing_variables' in environ: testenv = environ['paste.testing_variables'] testenv['req'] = req testenv['response'] = response testenv['tmpl_context'] = tmpl_context testenv['app_globals'] = self.globals testenv['config'] = conf testenv['session'] = locals.session testenv['cache'] = locals.cache return True, locals return False, locals
def _setup_app_env(self, environ): """Setup Request, Response and TurboGears context objects. Is also in charge of pushing TurboGears context into the paste registry and detect test mode. Returns whenever the testmode is enabled or not and the TurboGears context. """ conf = self.config testing = False # Setup the basic global objects req = Request(environ) req._fast_setattr('_language', self.lang) req._fast_setattr('_response_type', None) resp_options = self.resp_options response = Response( content_type=resp_options['content_type'], charset=resp_options['charset'], headers=resp_options['headers'] ) # Setup the translator object translator = _get_translator(self.lang, tg_config=conf) if self.strict_tmpl_context: tmpl_context = TemplateContext() else: tmpl_context = AttribSafeTemplateContext() app_globals = self.globals locals = RequestLocals() locals.response = response locals.request = req locals.app_globals = app_globals locals.config = conf locals.tmpl_context = tmpl_context locals.translator = translator locals.session = environ.get('beaker.session') # Usually None, unless middleware in place locals.cache = environ.get('beaker.cache') # Usually None, unless middleware in place environ['tg.locals'] = locals # Register Global objects registry = environ['paste.registry'] registry.register(request_local.config, conf) registry.register(request_local.context, locals) if 'paste.testing_variables' in environ: testing = True testenv = environ['paste.testing_variables'] testenv['req'] = req testenv['response'] = response testenv['tmpl_context'] = tmpl_context testenv['app_globals'] = self.globals testenv['config'] = conf testenv['session'] = locals.session testenv['cache'] = locals.cache return testing, locals, registry