0

__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 login_url = request.route_url(login) File "D:\Py3Env\lib\site-packages\pyramid-1.3.3-py3.2.egg\pyramid\url.py",第 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” , line 386, in sourcelines source = f.read() UnicodeDecodeError: 'gbk' codec can't decode bytes in position 2080-2081: illegal l multibyte sequence

有人知道为什么吗?

4

1 回答 1

0

我想你想改变

request.route_url(login)

request.route_url('login')
于 2012-10-11T03:38:13.083 回答