from tg import json_encode, responsefrom tg.render import _get_tg_varsdef render_jsonp(template_name, template_vars, **kwargs):callback = template_name or kwargs.pop('callback', None) or 'callback'for key in _get_tg_vars():del template_vars[key]response.headers['Content-Type'] = 'text/javascript'return '%s(%s)' % (template_name, json_encode(template_vars))from myapp.config.app_cfg import base_configbase_config.render_functions['jsonp'] = render_jsonpbase_config.mimetype_lookup = {'.jsonp': 'text/javascript'}

courtesy of Pederson:


comments powered by Disqus

About Yusuke Tsutsumi
I work at Zillow. I focus on tools and services for developer productivity, including build and testing.

My other interests include programming language design, game development, and learning languages (the non-programming ones).