4

web.py を使用して単純な HTML テンプレートを作成していますが、基本的なアプリを実行しようとするたびにシステムがエラーをスローし続けます。診断方法がわかりません。完全なトレースバックを以下に示します。誰かが診断方法についてアイデアを持っていますか?

誰かがこのリンクで同様の質問をしましたが、答えはありませんでした: web.py の継承?

ファイルを模倣しているソース: http://learnpythonthehardway.org/book/ex50.html

HTML ファイル:

<html>
    <head>
        <title>Gothons Of Planet Percal #25</title>
    </head>
<body>

$if greeting:
    I just wanted to say <em style="color: green; font-size: 2em;">$greeting</em>.
$else:
    <em>Hello</em>, world!

</body>

app.py:

import web

urls = (
  '/', 'Index'
)

app = web.application(urls, globals())

render = web.template.render('templates/')

class Index(object):
    def GET(self):
        greeting = "Hello World"
        return render.index(greeting = greeting)

if __name__ == "__main__":
    app.run()

トレースバック

Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/web/wsgiserver/__init__.py", line 1245, in     communicate
    req.respond()
  File "/Library/Python/2.7/site-packages/web/wsgiserver/__init__.py", line 775, in respond
self.server.gateway(self).respond()
  File "/Library/Python/2.7/site-packages/web/wsgiserver/__init__.py", line 2018, in respond
    response = self.req.server.wsgi_app(self.env, self.start_response)
  File "/Library/Python/2.7/site-packages/web/httpserver.py", line 268, in __call__
    return self.app(environ, xstart_response)
  File "/Library/Python/2.7/site-packages/web/httpserver.py", line 236, in __call__
    return self.app(environ, start_response)
  File "/Library/Python/2.7/site-packages/web/application.py", line 276, in wsgi
    result = self.handle_with_processors()
  File "/Library/Python/2.7/site-packages/web/application.py", line 246, in     handle_with_processors
    return process(self.processors)
  File "/Library/Python/2.7/site-packages/web/application.py", line 243, in process
    raise self.internalerror()
  File "/Library/Python/2.7/site-packages/web/application.py", line 467, in internalerror
    return debugerror.debugerror()
  File "/Library/Python/2.7/site-packages/web/debugerror.py", line 305, in debugerror
    return web._InternalError(djangoerror())
  File "/Library/Python/2.7/site-packages/web/debugerror.py", line 290, in djangoerror
    djangoerror_r = Template(djangoerror_t, filename=__file__, filter=websafe)
  File "/Library/Python/2.7/site-packages/web/template.py", line 844, in __init__
    code = self.compile_template(text, filename)
  File "/Library/Python/2.7/site-packages/web/template.py", line 922, in compile_template
    ast = compiler.parse(code)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/compiler/transformer.py", line 51, in parse
    return Transformer().parsesuite(buf)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/compiler/transformer.py", line 128, in parsesuite
    return self.transform(parser.suite(text))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/compiler/transformer.py", line 124, in transform
    return self.compile_node(tree)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/compiler/transformer.py", line 167, in compile_node
    raise WalkerError, ('unexpected node type', n)
WalkerError: ('unexpected node type', 339)
4

1 に答える 1