我的目标是将应用程序从 python2 升级到 python3。该应用程序使用以下包:flask、flask-admin、gevent(协程)、socketio。Flask 决定离开,剩下的包要换掉。已经多次尝试更换软件包:
- Tornado + SockJS:由于缺少 SockJS 通道,需要大量额外的代码
- Flask-aiohttp:在授权期间, request.form['username'] 抛出错误:
回溯(最近一次通话最后):
File "/home/user/.env/rbaio34/lib/python3.4/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/home/user/.env/rbaio34/lib/python3.4/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/user/.env/rbaio34/lib/python3.4/site-packages/flask/app.py",line 1381, in handle_user_exception reraise(exc_type, exc_value, tb)
File "/home/user/.env/rbaio34/lib/python3.4/site-packages/flask/_compat.py",line 33, in reraise raise value
File "/home/user/.env/rbaio34/lib/python3.4/site-packages/flask/app.py",line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/home/user/.env/rbaio34/lib/python3.4/site-packages/flask/app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args)
File "/home/user/workspace/aiolina/aiolina.py", line 33, in login username = request.form['username']
File "/home/user/.env/rbaio34/lib/python3.4/site-packages/werkzeug/local.py", line 338, in __getattr__
return getattr(self._get_current_object(), name)
File "/home/user/.env/rbaio34/lib/python3.4/site-packages/werkzeug/utils.py", line 71, in __get__
value = self.func(obj)
File "/home/user/.env/rbaio34/lib/python3.4/site-packages/werkzeug/wrappers.py", line 488, in form
self._load_form_data()
File "/home/user/.env/rbaio34/lib/python3.4/site-packages/flask/wrappers.py", line 165, in _load_form_data
RequestBase._load_form_data(self)
File "/home/user/.env/rbaio34/lib/python3.4/site-packages/werkzeug/wrappers.py", line 360, in _load_form_data
mimetype, content_length, options)
File "/home/user/.env/rbaio34/lib/python3.4/site-packages/werkzeug/formparser.py", line 193, in parse
content_length, options)
File "/home/user/.env/rbaio34/lib/python3.4/site-packages/werkzeug/formparser.py", line 103, in wrapper
exhaust()
File "/home/user/.env/rbaio34/lib/python3.4/site-packages/werkzeug/wsgi.py", line 977, in exhaust
self.read(chunk)
File "/home/user/.env/rbaio34/lib/python3.4/site-packages/werkzeug/wsgi.py", line 994, in read
if to_read and len(read) != to_read:TypeError: object of type 'generator' has no len()
那么,Flask-aiohttp 工作可以做些什么呢?或者用什么包代替?