Writing Text Files

Help
2012-01-05
2013-04-25
  • Eliott Minkovitch

    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")
          f.write("Hello World!")
          f.close()

    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,
    Eliott

     
  • Eric Brehault

    Eric Brehault - 2012-01-05

    Hello,

    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:
    wget http://locahost:8080/Plone/db/myagent/runAgent
    possibly from a crontab or a Windows schedule as explained here:
    https://sourceforge.net/projects/plomino/forums/forum/538558/topic/4840756

    (the difference being that it will actually download the file)

    eric

     
  • Eliott Minkovitch

    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?

    Thank you
    Eliott

     
  • Eliott Minkovitch

    Yes, you are right, it works! Thank you again.

    Eliott

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks