[Zope] Re: Writing to LocalFS

Jonothan Farr jfarr@real.com
Thu, 22 Jun 2000 10:27:01 -0700


> Again, after some searching, I am looking for the syntax to write  a
> file / append to a file in a Local File System.
>
> This is certainly where my Python days seem to slow my down b/c I
> would have just:
>
> contents = open('/path/file.txt', "r")
>
> to read and
>
> contents = open('/path/file.txt', "a")
>
> to append.
>
> I am sure that I am missing some bit of Zope Zen here...
>
> Please point me in the right direction...
>

To write a new file you would use the manage_upload method. To append a file,
you could read the contents of an existing file, append your data, then call
manage_upload to overwrite the file. See the LocalFS/DTML faq at
http://www.zope.org/Members/jfarr for information on how to access the contents
of a local file.

You may also consider just using an external method to do what you're trying to
accomplish.

--jfarr