[Zope-PTK] Upload images into ZClass based objects

Mike Pelletier mike@digicool.com
Mon, 20 Mar 2000 13:57:40 -0500 (EST)


On Mon, 20 Mar 2000, Chip Vanek wrote:

> 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?

    They store the data in the ZODB.  This is unlikely to change.

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

    Images are almost never stored as simple attributes in Zope.  By
'simple attribute', I mean an attribute which is not itself a Zope
object.  Given that, any Folderish object full of Image objects will look
like an object with Image attributes.  Unfortunately, there is presently
no Folderish, PTK-aware object, so if you want something that is both
content and a container, you'll have to write it.  Or, if your needs are
general enough, create a Tracker issue describing them and it might be
something suitable for the PTK.

> 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.

    A ZClass is a class which is created entierly through-the-web.  They
do not exist on the filesystem, but rather in the ZODB.  
(/Control_Panel/Products/aProduct/aZClass)  What the various PortalContent
classes do is make themselves available as a ZClass's base class, but they
are not ZClasses.

> I will move to the latest code and try image.py, but I think that
> it still will not completely meet my needs.

    No, not if your needs include serving them from and uploading them to
the filesystem.

> >def populate_folder(self, filename):
> >    file = open(filename).read()
> >    self.addImage('id', file, 'Title', 'Description of this image')

> 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.

    It is a file on the server.  You can probably figure out how to
receive uploads by looking at the Image wizard and add method.  The wizard
accepts uploads.

Mike.

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