[Zope-DB] updating fields in a zsql method programmatically
onsombal
onsombal at yahoo.com
Mon Aug 27 09:59:15 EDT 2007
Here's the scenario:
1. "insertNew" is a Z SQL Method for creating a new record in pgsql "table1"
Argument list = field1, field2, field3
SQL Query:
INSERT INTO table1 (field1, field2, field3)
VALUES (
<dtml-sqlvar field1 type="string">,
<dtml-sqlvar field2 type="string">,
<dtml-sqlvar field3 type="string">)
2. "call_insertNew" is a python script that is called as an "After
Validation Script" by a pfg form
request = container.REQUEST
RESPONSE = request.RESPONSE
form = request.form
changed_field1 = form.get('field1')
changed_field1 = "a new computed value"
field1 = changed_field1
#create a new record with form field results for field2 & field3, and a
computed value for field1
context.insertNew()
*************
It's easy to insert and update Z SQL Methods directly from form field
results.
It's easy to read form field results (e.g. request.field2) and do
comparisons, etc.
I am struggling to understand how one can change a form field result with a
computed value from a python script.
Either of the following returns an error:
form.get('field1') = changed_field1
request.field1 = changed_field1
and...
field1 = changed_field1
...the value doesn't get posted to the pgsql record. Instead the pgsql
field1 value remains what the request.field1 value was originally.
Any direction is appreciated... Jim
--
View this message in context: http://www.nabble.com/updating-fields-in-a-zsql-method-programmatically-tf4335404.html#a12347343
Sent from the Zope - DB mailing list archive at Nabble.com.
More information about the Zope-DB
mailing list