[Zope] Upload files, set properties, search props

Paul Winkler pw_lists@slinkp.com
Mon, 19 May 2003 12:45:42 -0400


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 doesn't
> 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 box
> 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:
http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/ScriptingZope.stx

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 this
to add a single property:

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


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


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

not necessary, the above will work.

the only advantage of a custom Product (whether zclass or filesystem-based
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!"