diff --git a/tg/configuration.py b/tg/configuration.py --- a/tg/configuration.py +++ b/tg/configuration.py @@ -270,18 +270,16 @@ class AppConfig(Bunch): Override this method to customize the way that ``app_globals`` and ``helpers`` are setup. """ config['pylons.app_globals'] = self.package.lib.app_globals.Globals() g = config['pylons.app_globals'] g.dotted_filename_finder = DottedFileNameFinder() - #config['pylons.helpers'] = self.package.lib.helpers - #config['pylons.h'] = self.package.lib.helpers def setup_sa_auth_backend(self): """This method adds sa_auth information to the config.""" if 'beaker.session.secret' not in config: raise TGConfigError("You must provide a value for 'beaker.session.secret' If this is a project quickstarted with TG 2.0.2 or earlier \ double check that you have base_config['beaker.session.secret'] = 'mysecretsecret' in your app_cfg.py file.") diff --git a/tg/render.py b/tg/render.py --- a/tg/render.py +++ b/tg/render.py @@ -28,17 +28,17 @@ def my_pylons_globals(): """ conf = pylons.config._current_obj() c = pylons.tmpl_context._current_obj() g = conf.get('pylons.app_globals') or conf['pylons.g'] try: - h = config.get('pylons.package').lib.helpers + h = conf.package.lib.helpers except (AttributeError, KeyError): h = Bunch() pylons_vars = dict( c=c, tmpl_context=c, config=conf, @@ -149,31 +149,29 @@ def _get_tg_vars(): locale = tg.request.accept_language.best_matches(), errors = getattr(tmpl_context, "form_errors", {}), inputs = getattr(tmpl_context, "form_values", {}), request = tg.request, auth_stack_enabled = 'repoze.who.plugins' in tg.request.environ, predicates = predicates, ) - # TODO in 2.2: we should actually just get helpers from the package's helpers - # module and dump the use of the SOP. - try: - helpers = config['pylons.package'].lib.helpers + h = config.package.lib.helpers except AttributeError, ImportError: - helpers = Bunch() + h = Bunch() root_vars = Bunch( c = tmpl_context, tmpl_context = tmpl_context, response = response, request = request, url = tg.url, - helpers = helpers, + helpers = h, + h = h, tg = tg_vars ) #Allow users to provide a callable that defines extra vars to be #added to the template namespace variable_provider = config.get('variable_provider', None) if variable_provider: root_vars.update(variable_provider()) return root_vars