[Zope-PTK] Upload images into ZClass based objects

Chip Vanek chip@upcast.com
Mon, 20 Mar 2000 10:47:47 -0800


>-----Original Message-----
>From: Mike Pelletier [mailto:mike@digicool.com]
>Sent: Monday, March 20, 2000 8:12 AM
>To: Chip Vanek
>Cc: zope-PTK@zope.org
>Subject: Re: [Zope-PTK] Upload images into ZClass based objects
>
>
>On Sun, 19 Mar 2000, Chip Vanek wrote:
>
>> Hi,
>> 
>> Does anyone know the best way to add support for binary files
>> to the PTK?  
>
>    Are you unhappy with the provided Image and File PTK objects?  They
>provide almost the same behaviour as the standard Zope ones.  In fact,
>they extend the standard ones, but perform some 'behaviour 
>modification'.

I just grabbed the latest CVS and see that you moved the DTML files
and added the image.py & file.py files.  I am out of sync and using the
PTK from Mar 3rd.  I will get back into the mainstream and see if those
new object meet the need.  Do they store the actual file or image in
the external file system or in the ZODB?

>
>> First I would like to add support for the inclusion
>> of gif/jpeg uploads into PTK derived objects.
>
>    I'm sure I am not understanding you...  You want the PortalContent
>class to manage a set of images?
>

No, I just want to be able to create Portal objects that have
imbedded images as an attribute.


>> The existing Document ZClass allows for the upload of text & 
>html with
>> python code like below:
>
>    If you have a Document ZClass, you are using a very old PTK.  There
>are no ZClass content objects presently, and haven't been since before
>IPC8...
>
I think I am just missunderstanding what a ZClass really is.  I was
assuming that the object that the "*.py" files creates and is registered
in the portalobject are ZClasses.

>> It looks like manage_addImage in Image.py is closest but what is the
>> right python syntax to call this in my ZClass file?
>
>    manage_addImage is inserted as a method in PortalFolder.  ...Wait a
>moment, no it's not.  'addImage' (from ZopePTK/PTKBase/Image.py) is.  
>Maybe we're not talking about the same thing at all.  I'll 
>pretend we are.  
>;-)
>
I will move to the latest code and try image.py, but I think that
it still will not completely meet my needs.

>    It's called on the folder you wish to add the image to.  
>It could be
>used from Python like this (as an external method):
>
>def populate_folder(self, filename):
>    file = open(filename).read()
>    self.addImage('id', file, 'Title', 'Description of this image')
>
>    (There are a couple more arguments with default values, see the
>source.)
>
Is the "filename" in the code above a path to a file local to
the Zope server or local to the users browser?  I would like to
have the user "upload" a file.


>> 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.
>
>    I'll leave this to someone with some experience in this sort of
>thing.
>
OK

Thanks for the reply,

Chip

>Mike.
>
>-- 
>Mike Pelletier                          email: mike@digicool.com
>Mild mannered software developer          icq: 7127228
>by day, super villain by night.         phone: 519-884-2434
>
>