Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flask Mongoengine WTForms update #812

Merged
merged 12 commits into from Mar 3, 2017
Merged

Flask Mongoengine WTForms update #812

merged 12 commits into from Mar 3, 2017

Conversation

noirbizarre
Copy link
Contributor

This PR supersedes #586, #654, #682 and #767 because they were dependent upgrades.
These PR have been merged into this one and all required fixes/refactorings applied:

  • flask_wtf.Form is now flask_wtf.FlaskForm and has a little signature change
  • flask_mongoengine has a new connection manager
  • wtform-json use StringField instead of the deprecated TextField which breaks every StringField instance (inherited or not) using default value (pending bug fix: Fixes (Python 3.6, tox, StringField default, latest versions...) kvesteri/wtforms-json#49), casting value to something else than a string or expected None as default

Consequence:

  • make use of mongoengine.get_db instead of the removed flask_mongoengine.connection.get_db
  • cleanup the form fields dependency tree: all fields expecting None as default/empty, inheriting from StringField but returning another type or using a default value now use udata.forms.field.Field as base class
  • Form(formdata, obj) calls are now Form(formdata, obj=obj)

Copy link
Member

@davidbgk davidbgk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -8,7 +8,7 @@
from flask_mongoengine.wtf import model_form # noqa

from flask_mongoengine.wtf.models import ModelForm as MEModelForm # noqa
from flask_wtf import Form as WTForm # noqa
from flask_wtf import FlaskForm # noqa
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#noqa still valid?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was happy too to remove it but sadly this is here because of the mandatory early wtforms_json.init()

@@ -52,6 +51,7 @@ def test_with_valid_uuid_string(self):

form.populate_obj(fake)

print(type(fake.id))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining print statement.

@noirbizarre noirbizarre merged commit 4dcd59f into opendatateam:dev Mar 3, 2017
@noirbizarre noirbizarre deleted the flask-mongoengine-wtf-update branch March 3, 2017 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants