[ZPT] Newbie: Editing / creating database records with single zpt
form + scripts?
James Carroll
jim at microbrightfield.com
Fri Apr 2 09:03:19 EST 2004
Hi,
I'm trying to put together a simple database list / edit / add for RMAs.
So far, I have it mostly working for editing. From my rma list page,
I have links to edit_rma?rma_id=1 and the zsql looks for the rma_id.
In my edit form:
I am doing: (which only repeats once, and works mostly)
<span tal:repeat"rma here/retrieve_rma">
Whenever I try the following:
<!-- S P A N tal:define="rma here/retrieve_rma" -->
I get a 'tuples indicies must be integers' error
<form action="update_rma">
<input type="hidden" name="rma_id" value="sample id"
tal:attributes="value rma/id | nothing" />
<table width="100%" border="0" cellpadding="2">
<tr>
<td width="27%" valign="bottom">
<div align="right">Customer Name</div>
</td>
<td width="73%" valign="bottom">
<input type="text" name="customerName" value="Current Customer Name"
size="50" tal:attributes="value rma/customerName | nothing"/>
</td>
</tr>
<tr>
So what I'd like to do instead is have a begin_edit_rma script like:
request = container.REQUEST
RESPONSE = request.RESPONSE
if request.has_key('rma_id'):
res = container.retrieve_rma(rma_id=request['rma_id'])
return container.edit_rma(rma=res.dictionaries()[0])
# otherwise we're starting blank
rma={}
rma['mbf_id']="newrmaid"
return container.edit_rma(rma)
and then just key off the rma dictionary
But nothing is working 'cause I don't exactly know what I'm doing.
Does anyone have a good example of editing and creating database
records?
Thanks!
-Jim
More information about the ZPT
mailing list