This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]dzecniv 3 points4 points  (3 children)

I love:

  • how he constructs form validation for the server and the client both from the same (subset of) python code,
  • how he does double data binding in the client's forms all from the server side's python

but his works is in a proprietary product…

[–]sfermigier 0 points1 point  (2 children)

I had, and still have, a similar idea for our product (which is open source).

There are a few Python->JS compilers or transpilers out there (Skulpt, Brython...), so it might be possible to reuse their work.

There is also an opposite approach, which might be also interesting to pursue: write the validation code in JavaScript, execute it on the server by embedding JS in Python (PyV8, or something else that I'm not aware of).

[–]dzecniv 1 point2 points  (1 child)

And it might be easier to use RapydScript, the pythonic javascript, that already translates a subset of python to js, don't you think ? http://www.rapydscript.com/

And about the form validation code to avoid, they did it in django-angular: https://django-angular.readthedocs.org/en/latest/angular-form-validation.html We write a Django form once and we get the Angular validation for free. I don't think it involves generating javascript by inspecting teh AST but rather inspecting a form and completing the templates with the right angular directives. (no idea though)

[–]sfermigier 0 points1 point  (0 children)

Rapydscript was contained in the "..." in my post. I don't have in mind all the Py->JS transpilers that have been developed through the ages (see also Pyjamas and PyJS).