[Zope] Upload files, set properties, search props

John Toews john@academiccolab.org
Mon, 19 May 2003 19:52:47 -0500

Thank you, pointing out I could do this without a Zclass is going to
save me time... The one thing I don't understand right now. The code
below adds a property to the containing folder, not the object I just
uploaded. How do I obtain the id so I can deal with that? (objects is
the name of my folder, it is a level under the script itself)

<dtml-call expr=3D"objects.manage_addFile(id=3D'', file=3Dfile,
<dtml-call expr=3D"objects.manage_addProperty('keywords', keywords,

I think the second one should be something like


-----Original Message-----
From: Paul Winkler [mailto:pw_lists@slinkp.com]=20
Sent: Monday, May 19, 2003 11:46 AM
To: zope@zope.org
Subject: Re: [Zope] Upload files, set properties, search props

On Mon, May 19, 2003 at 02:57:46PM -0500, John Toews wrote:
> Hello All,
> I am (very) new to Zope and am trying to figure out how exactly to
> implement what I want. I have read most of the Zope book and it
> seem to go into the depths I want, but please feel free to point me to
> better manual(s). What I want to be able to do is:
> - Present the user a form with to upload a file and, for now, a text
> for keywords (I've done this already)
> - Save the file to a folder and set a property for the keywords (I can
> save to a folder with the generic File object [using
> foldername.manage_addFile], but how do I create & set the keyword
> property)

the details vary depending on whether you want 1 property per keyword,
or 1 property for all keywords. but the basics can be gleaned from
the online zope book:

read the section on "The Zope API". There are examples of adding and
changing properties.

e.g. in the script that's the target of your form, do something like
to add a single property:

request =3D context.REQUEST
my_folder.manage_addProperty('keywords', request.get('keywords'),

> - Catalog the keywords property and be able to search it (Haven't even
> attempted yet)

no problem, just give youtr catalog a KeywordIndex with the name of your

> I believe the "correct" way to do this would be a Zclass using the
> base class and a property sheet.

not necessary, the above will work.

the only advantage of a custom Product (whether zclass or
product) is that it can be made to support automatic cataloging
so you don't have to periodically update the catalog.


Paul Winkler
home:  http://www.slinkp.com
"Muppet Labs, where the future is made - today!"

Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists -=20
 http://mail.zope.org/mailman/listinfo/zope-dev )