2016-09-05 3 views
1

Я получаю ошибку «AttributeError: объект« Request »не имеет атрибутов« params »в библиотеке falcon на python3, ubuntu.AttributeError: объект 'Request' не имеет атрибута 'params'

запрос URL = 127.0.0.1:8000/user?name=abc

from wsgiref import simple_server 
import falcon 

class user(object): 
    def on_get(self, req, resp): 
     print(req.params['name']) 

api = application = falcon.API() 

usr = user() 
api.add_route('/user', usr) 

if __name__ == '__main__': 
    http = simple_server.make_server('127.0.0.10', 8000, api) 
    http.serve_forever() 

В приведенном выше коде я не могу получить доступ к req.params

+0

Какую версию вы используете? – joarleymoraes

+0

Python 3.4, Falcon 1.0 и Ubuntu 14 – pikkupr

ответ

0

Если вы используете версию 1.0, то знать следующее разрывного изменения:

An option was added to toggle automatic parsing of form params. Falcon will no longer automatically parse, by default, requests that have the content type "application/x-www-form-urlencoded"...

Applications that require this functionality must re-enable it explicitly, by setting a new request option that was added for that purpose, per the example below:

app = falcon.API() 
app.req_options.auto_parse_form_urlencoded = True 

https://github.com/falconry/falcon/blob/master/CHANGES.rst