[Zope] Replace files in a specific directory using pythonscript
Heimo Laukkanen
huima@fountainpark.org
Thu, 07 Nov 2002 21:46:16 +0200
>I know it is possible to upload a new file replacing the file for a
>certain
>ID because in the zope management interface this is done by editing >the
>FileObject with the specified ID.
>I read in the bugcollector that the method "updata_data" cannot be >used,
>instead "manage_upload" should be used.
...
>Can anyone provide me with a sample python script that uses (or clues
>how to
>use) manage_upload to upload this file to the correct ID?
I don't have a sample script, but some clues to help you on. First of
all, learn to check and search help from the Zope Books API section
and/or the help in your Zope server. These files give you some idea
atleast.
And then the best source for help is the source code. If you see
something done in the Zope interfaces etc. you can try to look for those
sources too, for some help.
But now for the real help:
With the form - listing all the files in the directory, you can get a
good idea from the Examples that come with Zope. There is the
FileLibrary example that shows you a lot.
For File object, the update function is manage_edit. So in your script
you will call this function for the object you want to update.
Below is how it is defined in the source ( lib/python/OFS/Image.py ):
def manage_edit(self, title, content_type, precondition='',
filedata=None, REQUEST=None):
Hope this helps.
-huima