get access to old tg.selector, tg.checker ....

9 views
Skip to first unread message

aspineux

unread,
Jul 9, 2008, 10:37:04 PM7/9/08
to TurboGears Trunk
Hi

I cannot find the way to access to old standard variable of tg1

I can see in render.py

def get_tg_vars():
"""Create a Bunch of variables that should be available in all
templates.

These variables are:

selector
the selector function
checker
....


But cannot find how to access them.
They don't look to be available in from the template

Thanks

aspineux

unread,
Jul 9, 2008, 11:26:19 PM7/9/08
to TurboGears Trunk
lokking at it more carefully I see :

identity is missing
maybe something like :

identity = request.environ.get('repoze.who.identity')

should do the trick, and maybe a bug :

tg_vars = Bunch(
selector=selector,
ipeek=ipeek,
cycle=cycle,
quote_plus=quote_plus,
checker=checker,
url = tg.controllers.url,
session=session,
config=config,
locale = tg.request.accept_language.best_matches(),
errors = getattr(tmpl_context, "form_errors", {}),
inputs = getattr(tmpl_context, "form_values", {}),
request = tg.request)

root_vars = {}
root_vars.update({'tg':'tg_vars'})

maybe last line should be

root_vars.update({'tg':tg_vars})

without quote ?



>
> Thanks

Mark Ramm

unread,
Jul 9, 2008, 11:33:55 PM7/9/08
to turbogea...@googlegroups.com
> maybe last line should be
>
> root_vars.update({'tg':tg_vars})
>
> without quote ?

That certainly looks like a bug. Fix going into SVN now....

aspineux

unread,
Jul 10, 2008, 12:29:24 AM7/10/08
to TurboGears Trunk
But how do I get access to this from inside the template ?

>>> data.keys()
['c', 'display', 'XML', 'tg_flash', 'contacts', 'defined', 'screen',
'sidebar_top', 'header', 'tmpl_context', 'value_of', 'HTML',
'sidebar_bottom', 'tg', 'ET', 'footer', 'contact_class',
'contact_classes']
>>> data['tmpl_context']
<pylons.util.AttribSafeContextObj at 0xac56fac
action=u'routes_placeholder', controller=u'root',
controller_url=u'contact/index', environ={'AUTH_TYPE': 'cookie',
'routes.route': <routes.route.Route ...300'}, form=DataGrid(None,
children=[], **{'fields': [('ID', 'id'), ('Cl...')]}), form_errors={},
form_values=UnicodeMultiDict([]), grid=FlexiGrid('flex', children=[],
**{'usepager': True, 'fetchUR...'}]}), identity=<repoze.who identity
(hidden, dict-like) at 179858284>, pylons=<pylons.util.PylonsContext
object at 0xac56fec>, start_response=<function repl_start_response at
0xad0fa04>, url=u'contact/index'>

BUT no tg_vars !!!
Nowhere !
Reply all
Reply to author
Forward
0 new messages