[Zope] How to import files via FTP and set attributes.

Gary Speer gspeer@linkline.com
Sat, 4 May 2002 10:36:59 -0700


I'm mildly experienced at Zope, yet haven't found the 'simple' way to
execute the following.  I been going in circles on this and all
suggestions as to how to approach the problem
would be appreciated.  Rather than correct the approaches I have been
trying, I think it best to get a fresh perspective.

Big Picture Objective:  User FTPs a batch of files into an empty zope
folder along
with a text document called contents.txt.
contents.txt has one line per uploaded file in CSV or similar parseable
layout that begins with the file name.
After the upload, the user triggers a posting process (a 'process the
upload' form buttom with Action=Do_It().
The executed Do_it object reads the text file and loops once per line,
for each line, it parses it into a file name and several attributes.
The object then writes the uploaded file content to a target folder as a
zope object having these attributes.

I am stuck at looping on and parsing the content of the contents.txt
file to get and pass the attributes to the add object method.  I figure
the solution is best executed with Python in the context of Zope, but I'm
stuck at figuring out the syntax for this namespace.
1)  syntax to loop on the content of a file, one line at a time.
2)  string syntax to parse the line into variables (I don't think an array
is needed.)
3)  modify object syntax to update each file's attributes with the
variables
(or add a new object such as an image object with the imported file's
contents.)
Suggestions, syntax, or pointers to how-tos all gratefully accepted.
Thank you!
Gary