flexx icon indicating copy to clipboard operation
flexx copied to clipboard

flex component along with django template

Open keinagae opened this issue 5 years ago • 6 comments

I found flex to be very interesting project and I was looking for a way to make it integrate able with django but not as separate server like this where we can proxy flask request to flex. but what I am looking at is not proxying but more like making it possible to hook flex component in django rendered template and instead of using tornado I am thinking to use django channels for server and was think to create a class based on django channels for PyComponents. More like vue components with out spa. so was thinking would it be possible to do that in flex or it will be a complete separate projects?

keinagae avatar Nov 22 '20 17:11 keinagae

That sounds like it would need quite a few changes in Flexx itself. Perhaps it would be best to try this in a fork first? If it's possible to generalize these changes we could consider implementing (some of them) in Flexx itself. What do you think?

almarklein avatar Nov 23 '20 10:11 almarklein

yes indeed we should try it in a fork and as for my understanding we will be replacing whole tornado implementation with django channels or with next async django releases and then as for widgets i think we will have to reimplement PyComponent

and can you suggest me good starting point to work on this?

keinagae avatar Nov 24 '20 19:11 keinagae

and also with pyscript is it possible to render from server for first time?

keinagae avatar Nov 24 '20 19:11 keinagae

If you want to integrate PyWidgets with another class, have a look at app/_component2.py. That code is quite complex. You could also consider wrapping instead of subclassing.

For replacing Tornado, have a look at this base class and this Tornado implementation.

and also with pyscript is it possible to render from server for first time?

You mean to precompile Python code to JS? Sure! See e.g. https://pscript.readthedocs.io/en/latest/api.html#pscript.py2js. You'd have to use the inspect module to get the source lines.

almarklein avatar Nov 30 '20 08:11 almarklein

no not generating js code but actual html as it will be help full for crawlers and search engines

keinagae avatar Dec 02 '20 09:12 keinagae

pscript is used to generate JS from Python code. No HTML there.

almarklein avatar Dec 03 '20 09:12 almarklein