- Python 3.4 (using virtualenv)
- Pyramid 1.5.2
- Jinja2 (as Template Engine)
- SimpleForm (hacked for compability with Python 3)
- FormEncode
So I encounter the error which from the stack trace I almost cannot conclude anything. By debugging SimpleForm (yes, you read it correctly... debugging) finally I able to capture the real error messages which is like
field submit not expected
or
field _csrf not expected
With the real error message in hand, the quick googling deliver me to this link: https://github.com/Pylons/pyramid_simpleform/issues/6
Oh ok, seems like I need to add something to my schema
class MySchema(Schema):
allow_extra_fields = True
filter_extra_fields = True
name = validators.UnicodeString(min=5)
value = validators.Int()
Yes, it's because of allow_extra_fields and filter_extra_fields, and the curiosity of "why" lead me to this page:
https://github.com/Pylons/pyramid_simpleform/blob/master/docs/index.rstwhich stated:
Note the use of the allow_extra_fields and filter_extra_fields attributes. These are recommended in order to remove unneeded fields (such as the CSRF) and also to prevent extra field values being passed through.Oh Desson, please RT*M!
No comments:
Post a Comment