decatur/NuCompRes

Saving state between requests

mertcetin opened this issue · 2 comments

As far as I know, every eval request has its own context. It can access all defined functions and classes but cannot access local variables defined in the workspace.

Is there a way to access an array of data created as a result of an eval request, from subsequent requests? Is persisting into a file an option which is then to be read in the subsequent requests ?

Or if I were to add this feature where should I start developing?

Thank you very much

Understood as a MATLAB question: Yes, simply use assignin():

eval('localFoobar=1+2; assignin(''base'', ''foobar'', localFoobar)');

In a broader sense: Do not use state. Try to adopt REST-principles. You could pass session data with each call from client to server. Or you could create a resource (resources are not state, of course) on the server which holds the data. These resources should then be persistent to survive a server restart.

And to iterate the Readme: Never ever deploy eval().

Thank you very much for your reply. I've handled it using closure functions and exporting those functions as resources.