def stdvars(): """Create a Bunch of variables that should be available in all templates. These variables are: useragent a UserAgent object with information about the browser selector the selector function checker the checker function tg_js the path to the JavaScript libraries ipeek the ipeek function cycle cycle through a set of values quote_plus the urllib quote_plus function url the turbogears.url function for creating flexible URLs identity the current visitor's identity information session the current cherrypy.session if the session_filter.on it set in the app.cfg configuration file. If it is not set then session will be None. locale the default locale inputs input values from a form errors validation errors request the cherrypy request config the cherrypy config get function Additionally, you can add a callable to turbogears.view.variable_providers that can add more variables to this list. The callable will be called with the vars Bunch after these standard variables have been set up. """ try: useragent = cherrypy.request.headers["User-Agent"] useragent = UserAgent(useragent) except Exception: useragent = UserAgent() if config.get('session_filter.on', None): session = cherrypy.session else: session = None vars = Bunch( useragent=useragent, selector=selector, tg_js="/" + turbogears.startup.webpath + "tg_js", tg_toolbox="/" + turbogears.startup.webpath + "tg_toolbox", widgets="/" + turbogears.startup.webpath + "tg_widgets", tg_static="/" + turbogears.startup.webpath + "tg_static", ipeek=ipeek, cycle=cycle, quote_plus=quote_plus, checker=checker, url = turbogears.url, identity=identity.current, session=session, config=config.get, locale = get_locale(), errors = getattr(cherrypy.request, "validation_errors", {}), inputs = getattr(cherrypy.request, "input_values", {}), request = cherrypy.request) for provider in variable_providers + variableProviders: provider(vars) deprecated_vars = DeprecatedBunch(vars) root_vars = dict() for provider in root_variable_providers: provider(root_vars) root_vars.update(dict(tg=vars, std=deprecated_vars)) return root_vars
def stdvars(): """Create a Bunch of variables that should be available in all templates. These variables are: checker the checker function config the cherrypy config get function cycle cycle through a set of values errors validation errors identity the current visitor's identity information inputs input values from a form ipeek the ipeek function locale the default locale quote_plus the urllib quote_plus function request the cherrypy request selector the selector function session the current cherrypy.session if the session_filter.on it set in the app.cfg configuration file. If it is not set then session will be None. tg_js the url path to the JavaScript libraries tg_static the url path to the TurboGears static files tg_toolbox the url path to the TurboGears toolbox files tg_version the version number of the running TurboGears instance url the turbogears.url function for creating flexible URLs useragent a UserAgent object with information about the browser Additionally, you can add a callable to turbogears.view.variable_providers that can add more variables to this list. The callable will be called with the vars Bunch after these standard variables have been set up. """ try: useragent = cherrypy.request.headers['User-Agent'] useragent = UserAgent(useragent) except Exception: useragent = UserAgent() if config.get('session_filter.on', None): session = cherrypy.session else: session = None webpath = turbogears.startup.webpath or '' tg_vars = Bunch( checker = checker, config = config.get, cycle = cycle, errors = getattr(cherrypy.request, 'validation_errors', {}), identity = identity.current, inputs = getattr(cherrypy.request, 'input_values', {}), ipeek = ipeek, locale = get_locale(), quote_plus = quote_plus, request = cherrypy.request, selector = selector, session = session, tg_js = '/' + webpath + 'tg_js', tg_static = '/' + webpath + 'tg_static', tg_toolbox = '/' + webpath + 'tg_toolbox', tg_version = turbogears.__version__, url = turbogears.url, useragent = useragent, widgets = '/' + webpath + 'tg_widgets', ) for provider in variable_providers: provider(tg_vars) root_vars = dict() root_vars['_'] = gettext for provider in root_variable_providers: provider(root_vars) root_vars['tg'] = tg_vars root_vars['ET'] = genshi_et return root_vars
def update_params(self, d): super(LocalizableJSLink, self).update_params(d) language = d.get('language') or get_locale() if language not in self.supported_languages: language = self.default_language d['link'] = d['link'] % {'lang':language}
def update_params(self, d): super(LocalizableJSLink, self).update_params(d) language = d.get('language') or get_locale() if language not in self.supported_languages: language = self.default_language d['link'] = d['link'] % {'lang': language}