Hi Eric, I am trying to write out a text file for export, so to test it, I entered this code into an agent, exdcuted from an action button,
f = open("eliott1.txt","w")
the agen crashes, but if I enter it directly into Python enterpreter, it works and the file is created. What needs to be done to make this work from a Plomino Agent?
Thanks and regards,
Plomino formula are based on standard Zope PythonScript.
PythonScript are secured, so they does not allow a lot of thing like importing modules, accessing the file system (like you try to), etc.
If you need to execute a code doing this kind of forbidden things, you must implement it into a product an deploy it on your server.
It might be a basic external method, or it can be a PlominoUtils plugin (as described here: https://github.com/plomino/Plomino/blob/github-main/docs/CUSTOMUTILS_HOWTO.txt )
In your case, if what you need is to extract data from Plomino and store it on your disk, there is an easier way:
create a Plomino agent which produces the text content download (by streaming it as a response).
And then make a script on your server which call this agent, like that:
possibly from a crontab or a Windows schedule as explained here:
(the difference being that it will actually download the file)
OK, that will work for me, as long as I can get the data out somewhere, locally is perfect. But how do you tell the agent to stream data? I thought it can only work silently in the background, manipulating data?
The agent can write directly into the current http response, and if you set the http header properly, it will produce a download.
Here is an example:
Yes, you are right, it works! Thank you again.
Log in to post a comment.