<div class="gmail_quote">On Thu, Dec 24, 2009 at 6:32 PM, MRAB <span dir="ltr"><<a href="mailto:python@mrabarnett.plus.com">python@mrabarnett.plus.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Victor Subervi wrote:<div><div></div><div class="h5"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Thu, Dec 24, 2009 at 3:28 PM, MRAB <<a href="mailto:python@mrabarnett.plus.com" target="_blank">python@mrabarnett.plus.com</a> <mailto:<a href="mailto:python@mrabarnett.plus.com" target="_blank">python@mrabarnett.plus.com</a>>> wrote:<br>

<br>
    Victor Subervi wrote:<br>
<br>
        Hi;<br>
        I have the following code:<br>
<br>
             try:<br>
               trueVal = form.getlist(storeColNames[i])<br>
               colNames.append(storeColNames[i])<br>
               if len(trueVal) > 1:<br>
                 trueVal = string.join(trueVal, ',')<br>
<br>
<br>
    Unless you're using a very old version of Python, you should be using<br>
    the string method:<br>
<br>
             trueVal = ','.join(trueVal)<br>
<br>
<br>
                 values.append(trueVal)<br>
               elif len(trueVal) == 1:<br>
                 print storeColNames[i], trueVal, '<br />'<br>
                 trueVal = '%s' % trueVal[0]<br>
                 values.append(trueVal)<br>
               if len(trueVal) > 0:<br>
                 sql = '%s="%s"' % (storeColNames[i], trueVal)<br>
                 sqlUpdate.append(sql)<br>
             except:<br>
               raise<br>
<br>
        This works fine except when storeColNames[i] returns no data.<br>
        Now, if I were dealing with getfirst instead of getlist, I could<br>
        easily put in a nonsense default data value such as '%$#' and<br>
        check for that. But how can I do that or something similar (and<br>
        preferably more elegant) with getlist, which takes only the one<br>
        name parameter?<br>
<br>
    You just need to check whether len(trueVal) == 0. Simple.<br>
<br>
<br>
The problem is that it doesn't see the value at all<br>
<br>
        trueVal = form.getlist(storeColNames[i])<br>
        test = ','.join(trueVal)<br>
        if len(test) == 0:<br>
          trueVal == ''<br>
 It simply doesn't register storeColNames[i] if there is nothing provided from the referring page. Here's a test printout:<br>
<br>
</blockquote></div></div>
[snip]<div class="im"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
You can see from the above part with breaks that "Availability" isn't logged. But it is in the insert statement...without a value, which throws an error. The complete code follows:<br>
<br>
</blockquote></div>
[snip]<br>
Try working through the code by hand for that value.</blockquote><div><br></div></div>Well I've done that. What happens is the storeColNames registers the "Availability" field naturally enough; however, as I stated before, the getlist doesn't fetch anything because there is nothing to fetch! No such value is passed! So, what I need to do is figure out a way to log the fact that no value is fetched. What I have currently, unfortunately, simply ignores the unfetchable value. As I stated before, I need to log the fact that no such value is obtained. Please...how do I do that??<br>
TIA,<br>beno<br>