[Zope] Give ":Record" modifier in forms access to python scritps [newbie]

Philippe Jadin philippe.jadin@123piano.com
Thu, 24 May 2001 18:41:44 +0200


Hello,

After a ten-times reading of the zopebook part about ":record" modifier that
can be used in html form in order to have records available for scripting,
I still can't understand how to use them.

I have a addform with (roughly) this :
(idea took from the guestbook example)

-----------------
<form action="addMediaAction" method="POST">

Filename :
<input type="text" name="filename" value="">

Describe your media: <br>
<textarea name="description" rows="10" cols="60"></textarea>

Completion (0-100%) : <br>
<input type="text" name="metadata.completion:record" value="100">

Color :<br>
<input type="text" name="metadata.color:record">

<input type="submit" value="Submit media">
</form>
------------------------

The  addMediaAction file is something like this :

--------------
<dtml-call expr="addMedia(filename, description, metadata)">
--------------

and the addMedia python script is :

------------------
"""
Create a new media entry.
"""
# assign the filename to the id var for the new doc

id=filename

# create the document
context.manage_addProduct['OFSP'].manage_addDTMLDocument(id, title="",
file=description)

# add the media properties to the object. It is submited in the form like
this : media.xxx:record
# arbitrary metadata can be submited by proper editing of the form.

doc=getattr(context, id)

# add each metadata to the object

# doc.manage_addProperty(metadata)

-----------

Now, I'd like to add each metadata.xxxx entry as a new property of the just
created object.

This way, I could add more metadata simply by editing the form.

So, in the python script, how can I tell : "run over each record in the
metadata record, and create a property with the name and value of each
record" ? Is it the right way to do this?

Thanks for your time !


Philippe Jadin
www.123piano.com