Am 24.10.2010 13:48 schrieb [email protected]:
The last line, I think, should read:
return '%s(%s)' % (callback, json_encode(template_vars))
Of course you're right with both remarks. It should be this:
def render_jsonp(template_name, template_vars, **kwargs):
callback = (template_vars['tg']['inputs'].get('callback')
or template_name or 'callback')
for key in _get_tg_vars():
del template_vars[key]
response.headers['Content-Type'] = 'text/javascript'
return '%s(%s)' % (callback, json_encode(template_vars))
Somewhat unpleasant here is that the JSONP controller now always has to
declare a callback or **kwargs parameter.
I guess we could solve this by creating an appropriate jsonp decorator
as replacement for the expose decorator. This could pop the callback
name from the query parameters and ignore the templ_context.
-- Christoph
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en.