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="objects.manage_addFile(id='', file=file, title='test')"> <dtml-call expr="objects.manage_addProperty('keywords', keywords, 'text')"> I think the second one should be something like objects.UPLOADED_FILE_ID.manage_addProperty... Thanks! -----Original Message----- From: Paul Winkler [mailto:pw_lists@slinkp.com] 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 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/ScriptingZop e.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!" _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )