开发者中心交流吧 关注:6,938贴子:13,046
  • 1回复贴,共1

想再请教一下关于PYTHON平台使用jinja模板的问题

只看楼主收藏回复

主要代码如下:
def render_template(template_name,**context):
extensions=context.pop('extensions',[])
globals=context.pop("globals",{})
jinja_env=Environment(
loader= FileSystemLoader('template') ,
extensions=extensions)
jinja_env.globals.update(globals)
return jinja_env.get_template(template_name).render(context)
调用时候是这样的:
re = c.execute(sql)
persons = c.fetchall()
return render_template('person.html',persons=persons,user=user)
代码结束是这样的:
app = webapp2.WSGIApplication([('/', Myperson),], debug=True)
from bae.core.wsgi import WSGIApplication
application = WSGIApplication(app)
使用的是webapp2框架
调试的时候发现提示:
Traceback (most recent call last): File "/home/bae/instanceall/instance0/pyruntime/lib/python2.7/site-packages/webapp2.py", line 1547, in __call__ return response(environ, start_response) TypeError: 'unicode' object is not callable
搞不清楚这个'unicode' object is not callable 是什么意思,是什么地方出问题了?
我把中间的模板文件换成任意标准的HTML文件都不行,应该不是HTML文件的问题。
是不是我的参数循环有问题,还是这个JINJA的模板引擎不行?



IP属地:广东1楼2012-10-10 18:32回复
    楼主您好,请您关注一下私信,里面有针对该问题所对应的处理方案。


    2楼2012-10-11 10:21
    回复