getlist question

Victor Subervi victorsubervi at gmail.com
Thu Dec 24 15:05:27 EST 2009


Hi;
I have the following code:

      try:
        trueVal = form.getlist(storeColNames[i])
        colNames.append(storeColNames[i])
        if len(trueVal) > 1:
          trueVal = string.join(trueVal, ',')
          values.append(trueVal)
        elif len(trueVal) == 1:
          print storeColNames[i], trueVal, '<br />'
          trueVal = '%s' % trueVal[0]
          values.append(trueVal)
        if len(trueVal) > 0:
          sql = '%s="%s"' % (storeColNames[i], trueVal)
          sqlUpdate.append(sql)
      except:
        raise

This works fine except when storeColNames[i] returns no data. Now, if I were
dealing with getfirst instead of getlist, I could easily put in a nonsense
default data value such as '%$#' and check for that. But how can I do that
or something similar (and preferably more elegant) with getlist, which takes
only the one name parameter?
TIA,
beno
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091224/510fb7aa/attachment.html>


More information about the Python-list mailing list