[Zope-PTK] Upload images into ZClass based objects

Chip Vanek chip@upcast.com
Sun, 19 Mar 2000 19:47:00 -0800


Hi,

Does anyone know the best way to add support for binary files
to the PTK?  

First I would like to add support for the inclusion
of gif/jpeg uploads into PTK derived objects.  The existing
Document ZClass allows for the upload of text & html with
python code like below:

 if file:
     if type(file) is not type(''):
         file=file.read()
         if file:
             self.text=file
             self._parse()

Were file is a string path to a file local to the
clients browser.  Now this code still does not work when
the document object is first created (another problem) but
does work when the document object is edited.

I looked through many of the files in the standard Zope
install (Image.py, load_site.py, ImageFile.py) and cannot
seem to get any of those functions to work.  It looks like
manage_addImage in Image.py is closest but what is the right
python syntax to call this in my ZClass file?

if imgfile:
    if type(imgfile) is not type(''):
	  manage_addImage('imgs/Pimage', imgfile, REQUEST=_.None)

Now, the ideal solution would allow all gif/jpef files to be
stored in the external file system and not inside the ZODB.
Does anyone know a way to allow the user to browse a local
file using a normal <input type="file"...> button and then
automagically upload the file to overwrite existing or create
a new file outside the ZODB.  At the same time create a new 
Zope object or update existing object with meta info about 
the uploaded item.  Elements of the new LocalFS product look
promising but do not support upload/writing to the files.

Right now I need to get gifs/jpegs uploaded into an existing
ZClass  but, I do not want my ZODB to ballon so need a follow
along better solution.

Thanks for any pointers.

Chip Vanek
e-Mail: chip@upcast.com