On Tue, 2002-03-26 at 08:29, Jeff Peterson wrote: <...>
Well, you need to execute the ZSQL method obviously, and you can do this more than one way:
One way to do it is to call it in a Script (python) and pass the information by the request namespace:
Script (python) ===============
data = context.your_sql([param=value]) #assuming you returned 1 row context.REQUEST.set('field', data[0]['colname']) return context.your_template(context)
then
<tr> <td><LABEL for="firstname">First name: </LABEL></td> <td><INPUT type="text" name="first_name" value="" tal:attributes="value request/field" tal:on-error="string:"> </td> </tr>
Thanks Jeff - this got me going again. I've decided to go this route, because it keeps the template very simple. My script ended up being: res = context.get_customer(personid=pid) d = res.dictionaries()[0] for k in d.keys(): context.REQUEST.set(k, d[k]) Since the column names are (intentionally) the same as the input field names, I can get away with just using they key values. Now that I think of it, this script is quite generic, except for the call to get_customer(). I'm going to have at least 2 more add/edit/seach sections within my site, and I'm going to end up copying all this stuff and just renaming one function call. It would be great if I could call this "populate" or something, and just pass the name of the sql query to execute. I'm not sure how to do this in Zope (in Python, I could just create a function object to execute, but I don't know if that's possible in zope, or if so, what the semantics are). I have an allergy to cutting/pasting code and only changing one thing. I'd really like to parameterize as much as possible. Any ideas? -- Colin Fox cfox@crystalcherry.com CF Consulting Inc. GPG Fingerprint: D8F0 84E7 E7CC 5C6C 9982 F1A7 A3EB 6EA3 BC97 572F