1
我已经安装了Pylons v0.9.7,并使用genshi创建了一个项目。 我试图编写一个简单的测试用例,但它不起作用。主塔“全球名称'c'未定义”
代码:member.py
coding: utf-8
import logging import foo.model
from foo.lib.base import *
log = logging.getLogger(__name__)
class MemberController(BaseController):
def index(self):
c.title="title"
c.mes="message"
return render('test.html')
代码:test.html的
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:py="http://genshi.edgewall.org/"
lang="ja">
<head>
<title>${c.title}</title>
</head>
<body>
<p>${c.mes}</p>
</body>
</html>
和错误信息(对数)
Error - <type 'exceptions.NameError'>: global name 'c' is not defined
请帮我找出错误。
捐赠是光作为提示? 我有你的书(python CookBook)! 我很荣幸。 此后,它再次尝试。 – Schaft 2010-01-12 05:22:54
啊!有效!谢谢Alex! 我明白“C was tmpl_context”。 我衷心地表示感谢。 – Schaft 2010-01-12 06:24:46