[Zope] Re: Odd problem updating a PostgreSQL DB

Evan Simpson evan@4-am.com
Fri, 13 Sep 2002 23:26:51 -0500


Tim Wilson wrote:
> On Fri, Sep 13, 2002 at 04:08:00PM -0500, Evan Simpson wrote:
>>My first reaction to these symptoms is that you've got a Z SQL Method 
>>with roughly the following in it somewhere:
>>
>><dtml-if score>
>>UPDATE ....
>></dtml-if>

Yah, sure enough:

>   <dtml-if our_score>our_score = <dtml-sqlvar our_score type="int"
> optional="true">,</dtml-if>
>   <dtml-if their_score>their_score = <dtml-sqlvar their_score
> type="int" optional="true">,</dtml-if>

I know it sounds weird, but leave off the ":int" marshalling flag on the 
input fields.  That way, zero will get passed to the code above as the 
string "0", which tests as true, rather than the integer 0, which tests 
as false.  An absent or blank string value will test false, skipping the 
update (which is why I presume those dtml-ifs are there in the first place).

You'll get the same level of input validation out of the type="int" 
attributes on your dtml-sqlvars as you would from the marshaller, but 
with the happy added bonus of being able to capture errors in context 
with a standard_error_message.

Cheers,

Evan @ 4-am