Run JS from your Python code via Socket #FrappeHack

7 Likes

This makes me so happy, I can’t like it enough. Thank you!!!

2 Likes

@rmehta, sorry for my silly question! Why it can be “Awesome”? It’s not a ant-pattern?

I think that the purpose of websocket is enable a publish - subscriber system, using rich JSON messages instead of send raw javacript from server to be evaluated!

In the same way I can ask for enable again the evaluation of custom Server scripts!

@max_morais_dmm The problem with custom server scripts is that it can be used to edit the file system and on the cloud we cannot really allow that. But yes if we can lock that down (maybe offer a restricted list of libraries to run - like we do in Jinja) that could work.

@max_morais_dmm, I’m asking about frappe.emit_js because if bad used, can broken everything!

Did you implemented a locker while uploading data? I gues in this case, you can have a lot of js that will be sent to the UI, but is not related with the actual page!

So it has to be used carefully. Do you see any security issues? Since it will be sent from the server-side.

I think we can use it for automatic syncing of models (locals) from the server and it will greatly improve user experience!