[Zope-PTK] Upload images into ZClass based objects
Mike Pelletier
mike@digicool.com
Mon, 20 Mar 2000 11:11:31 -0500 (EST)
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'.
> 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?
> 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...
> 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.
;-)
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.)
> 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.
Mike.
--
Mike Pelletier email: mike@digicool.com
Mild mannered software developer icq: 7127228
by day, super villain by night. phone: 519-884-2434