form data validation using wtf forms #575
Replies: 2 comments 1 reply
-
@sandeep-gh - very interesting analysis. Actually Tim and I come from a flask background e.g. we worked on Integrating all these different frameworks is unfortunately much harder then we would wish since core softare architecture and software engineering aspects have been having a low priority in most of the frameworks involved and you'll see ugly workarounds and APIs all over. Our own code is unfortunately not exempt - we also chimed in in doing work-around more often than proper solutions. So it would be good if we would find better integration ways to make the transition from one framework to another and the interoperability between the different frameworks much smoother. |
Beta Was this translation helpful? Give feedback.
-
The other reason is the ID generation aspect of justpy. This needs a more careful look as to why we can't stick with same id when json is returned from frontend. For my project, I might not use justpy id generation but instead assign them externally. |
Beta Was this translation helpful? Give feedback.
-
I was attempting to use wtforms (https://flask-wtf.readthedocs.io/en/1.0.x/) to bake in data validation. Turned out to be much harder than I had envisioned.
First, the event data used in wtforms in some sort of multidict. It seems that the request json object could have multiple entries for same keys which necessitates use of multidict.
If so, we should look into implications for justpy.
Second, and the main reason why this didn't work out, is because I am not able to associate/link components at creation time with
data derived from event handling.
So, when form is created its component looks as follows:
but the data in event handler is :
The id's are different for the form components. Here is the unfinished code if case anyone has ideas or want to take a stab at it:
https://github.com/sandeep-gh/justpy_form_wtf_validation/blob/main/jp_and_wtforms.py
Beta Was this translation helpful? Give feedback.
All reactions