__init__.py
定义:
config.add_route('to_login', '/manage')
config.add_route('login', '/manage/login')
访问http://xxx.xxx.0.1:6543/manage/
成功访问login.pt
但是以html格式:
<div class="login-form">
<form class="login" action="/manage/login" method="post">
<h1 i18n:translate="">登录</h1>
提交后我收到错误:
2012-10-11 11:22:39,365 ERROR [waitress][Dummy-1] Exception when serving /manage
/login
Traceback (most recent call last):
File "D:\Py3Env\lib\site-packages\pyramid_debugtoolbar-1.0.2-py3.2.egg\pyramid
_debugtoolbar\toolbar.py", line 122, in toolbar_tween
response = _handler(request)
File "D:\Py3Env\lib\site-packages\pyramid_debugtoolbar-1.0.2-py3.2.egg\pyramid
_debugtoolbar\panels\performance.py", line 69, in noresource_timer_handler
result = handler(request)
.......... .......... response = view(request) 在登录时输入文件“d:\ py3env \ scripts \ dyncms \ dyncms \ view \ login.py”,第51行 login_url = request.route_url(登录) 文件“D:\ Py3Env \ lib \ site-packages \ pyramid-1.3.3-py3.2.egg \ pyramid \ url.py”,lin e 208,在route_url中 引发KeyError('没有这样的路由名为%s'%route_name) KeyError:'没有名为'
的此类路线During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Py3Env\lib\site-packages\waitress-0.8.1-py3.2.egg\waitress\channel.py
", line 329, in service
task.service()
......... ......... 文件“D:\ Py3Env \ lib \ site-packages \ pyramid_debugtoolbar-1.0.2-py3.2.egg \ pyramid _debugtoolbar \ tbtools.py“,第386行,在源代码行中 source = f.read() UnicodeDecodeError:'gbk'编解码器无法解码位置2080-2081中的字节:illega l多字节序列
有谁知道为什么?
答案 0 :(得分:0)
我想你要改变
request.route_url(login)
到
request.route_url('login')