[Zope] What is the Python script that is similar to a dtml-in call

Small Business Services toolkit at magma.ca
Mon May 31 12:54:08 EDT 2004


<snip>
From: Larry McDonnell

Within the dtml-in statement, I use serial_number to find the record in the
db. I checking for a valid serial number but what is return from the dtml-in
statement if the serial number lookup is not found.
</snip>

If you are doing individual db look-ups within a dtml-in loop then you need
to check the return value from each db look-up call:

eg.

<dtml-in lookup_header_record>
  <dtml-let rstatus="dbGet(_['sequence-item'])">
    <dtml-if "rstatus != 'success'">
        No success for item: <dtml-var sequence-item><br>
    </dtml-if>
  </dtml-let>
</dtml-in>

Alternatively, you could store the 'failed' returns and then handle them all
at once:


<dtml-call "REQUEST.set('errflag', {})">
<dtml-in lookup_header_record>
  <dtml-let rstatus="dbGet(_['sequence-item'])">   ***dbGet is your db
lookup function
    <dtml-if "rstatus != 'success'">   *** dbGet must return some status
value
       <dtml-call "errflag.update({_['sequence-item'] : 'failed'})">
    </dtml-if>
  </dtml-let>
</dtml-in>

<dtml-if "errflag != {}">
  Errors during db lookup: <dtml-var errflag>
</dtml-if>

or

<dtml-if "errflag != {}">
  <dmtl-in "errflag.keys()">
      Errors during db lookup: <dtml-var "errflag[_['sequence-item']]">
failed<br>
  </dtml-in>
</dtml-if>


HTH

Jonathan

Caveat:  above code is NOT tested






More information about the Zope mailing list