我想調試燒瓶0.8應用程序中的BuildError。在嘗試呈現多步表單的第2部分時,函數personal_open_account()
中發生錯誤。第1步呈現表格,如果已驗證,則執行
return redirect(url_for('personal_open_account', step='2'))
。也就是說,它自稱,但是有一個新的step
參數。第1步成功完成,並在表單驗證(我可以看到一個打印語句我把),但我隨後立即收到BuildError:如何調試燒瓶BuildError
Traceback (most recent call last):
File "/Users/sth/.virtualenvs/sb/lib/python2.7/site-packages/flask/app.py", line 1518, in __call__
return self.wsgi_app(environ, start_response)
File "/Users/sth/.virtualenvs/sb/lib/python2.7/site-packages/flask/app.py", line 1506, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/Users/sth/.virtualenvs/sb/lib/python2.7/site-packages/flask/app.py", line 1504, in wsgi_app
response = self.full_dispatch_request()
File "/Users/sth/.virtualenvs/sb/lib/python2.7/site-packages/flask/app.py", line 1264, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Users/sth/.virtualenvs/sb/lib/python2.7/site-packages/flask/app.py", line 1262, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/sth/.virtualenvs/sb/lib/python2.7/site-packages/flask/app.py", line 1248, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/Users/sth/dev/sb_flask/sb/views/personal.py", line 333, in personal_open_account
return redirect(url_for('personal_open_account', step='2'))
File "/Users/sth/.virtualenvs/sb/lib/python2.7/site-packages/flask/helpers.py", line 208, in url_for
return ctx.url_adapter.build(endpoint, values, force_external=external)
File "/Users/sth/.virtualenvs/sb/lib/python2.7/site-packages/werkzeug/routing.py", line 1605, in build
raise BuildError(endpoint, values, method)
BuildError: ('personal_open_account', {'step': '2'}, None)
功能本身看起來像:
@app.route('/personal/save/<product_type>/<slug>/open-account', methods=['GET', 'POST'])
def personal_open_account(product_type, slug):
...