[Zope] Adding ZClass instances using a Python script.
Luca Manini
manini@flashnet.it
Tue, 26 Mar 2002 17:34:34 +0100
Hi,
the question is very simple, could be a FAQ but does not seems to be a
Frequently ANSWERED Question, so here it goes:
1) I have a Product called PhoneBookProduct (done via ZMI),
2) I have a ZClass in it, called Person,
3) the Person class has two properties name and phone, defined in a
property sheet named basic,
4) I have a view for those properties.
5) I have a test Folder to test my Product.
So far so good, I can add Person instances (Id asked) and then I can
edit the properties; all this with the standard magically created
stuff.
Now I want to do my own interface, so I create the obvious index_html:
<dtml-var standard_html_header>
<table>
<tr>
<th>id
<th>name
<th>phone
</tr>
<dtml-in "objectValues('Person')">
<tr>
<td><dtml-var id>
<td><dtml-var name>
<td><dtml-var phone>
</tr>
</dtml-in>
<table>
<form method="post">
<br>name: <input name="name" value="foo">
<br>phone: <input name="phone" value="555">
<br><input type="submit" name="add:method" value=" Add ">
</form>
where "add" (the action of the add button) should be a Python Script
that creates a Person instance, edit the properties as of REQUEST, and
add the istance to some folder (lets say test, that contains both the
index_html and the add Python Script).
What are the magic lines to put into "add"?
TIA, Luca