<div class="gmail_quote">On Thu, Dec 3, 2009 at 8:02 AM, Victor Subervi <span dir="ltr"><<a href="mailto:victorsubervi@gmail.com">victorsubervi@gmail.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;">
<div><div></div><div class="h5"><div class="gmail_quote">On Thu, Dec 3, 2009 at 6:07 AM, Victor Subervi <span dir="ltr"><<a href="mailto:victorsubervi@gmail.com" target="_blank">victorsubervi@gmail.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;">
<div class="gmail_quote">On Wed, Dec 2, 2009 at 4:08 PM, MRAB <span dir="ltr"><<a href="mailto:python@mrabarnett.plus.com" target="_blank">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;">


<div><div></div><div>Victor Subervi wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi;<br>
I have spent 2-3 hours trying to track this bug. Here's the code snippet:<br>
<br>
  form = cgi.FieldStorage()<br>
  fn = getattr(options, 'products')<br>
  ourOptionsNames = []<br>
  optionsNames, doNotUse  = fn('names')<br>
  for name in optionsNames:<br>
    test = table + '-' + name<br>
    print test<br>
    check = form.getfirst(test, '')<br>
    print check<br>
    if check != '':<br>
      ourOptionsNames.append(name)<br>
 Now, when it looks through with test=='products', it doesn't report that any of the values from the form are checked. However, when I explicitly write out something like:<br>
print form.getfirst('products-sizes', '')<br>
which I checked on the form from the referring page, it does in fact print out! My test prints show that 'products-sizes' is being passed to "check" and should therefore be appended to "ourOptionsNames". But it isn't! What am I missing here??<br>



<br>
</blockquote></div></div>
What do the print statements actually print? Please copy and paste their<br>
output.<br></blockquote><div><br></div></div>For the part in question they print __nothing__. That's the point. <br><font color="#888888">V<br>
</font></blockquote></div></div></div>I believe I mentioned in my first post that the "print test" does print the exact fields being called from the referring page. The "print check" prints nothing. Another thing that's strange is that there are two tables of fields in the referrer page; it will print the first of those tables--whichever of the two I choose--but not the latter. Perhaps this is a bug in the cgi interface? Perhaps I should migrate this to mod_python?<br>

TIA,<br><font color="#888888">V<br>
</font></blockquote></div>Perhaps the following code, which is from the referrer, will help. I don't see how it makes any difference at all, since all the code is printed between the opening form and the submit button:<br>
<br>#!/usr/bin/python<br><br>import cgitb; cgitb.enable()<br>import MySQLdb<br>import cgi<br>import sys,os<br>sys.path.append(os.getcwd())<br>from login import login<br>import string<br>import options<br>from particulars import optionsTables, addStore<br>
<br>def chooseOptions():<br>  print '''Content-Type: text/html\r\n<br><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><br><html><br><form action='chooseOptions2.py' method='post'><br>
'''<br>  storesTables = []<br>  junkStores = string.join(addStore(), ', ')<br>  for table in optionsTables():<br>    if table not in ('particulars', junkStores):<br>      storesTables.append(table)<br>
  bgcolors = ['F2F6D3', 'F2DDD3', 'D7DDD3']<br>  myOptions = []<br>  myMeanings = []<br>  for table in storesTables:<br>    try:<br>      fn = getattr(options, table)<br>      opts, means = fn('names')<br>
      myOptions.append(opts)<br>      myMeanings.append(means)<br>    except:<br>      pass<br>  i = 0<br>  print "<font size='4'><b>Please select which of the option groups below you would like to associate with each store. On the next page, you will have the opportunity to select which options within each option group you would like to have in your selection for each store.</b></font><br /><br />"<br>
  for table in storesTables:<br>    print "<table align='center' bgcolor='#%s' border='1'>\n <tr>\n  <td colspan='3'>\n" % bgcolors[i]<br>    print "<h1 align='center'>%s</h1>\n  </td>\n </tr>\n" % (table[0].upper() + table[1:])<br>
    print " <tr>\n  <td align='center'><b>Option</b></td>\n  <td align='center'><b>Definition</b></td>\n  <td align='center'><b>Check</b></td>\n </tr>\n"<br>
    j = 0<br>    while j < len(myOptions[0]):<br>      print " <tr>\n  <td>%s</td>\n  <td>%s</td>\n  <td align='center'><input type='checkbox' name='%s' /></td>\n </tr>\n" % (myOptions[0][j], myMeanings[0][j], table + '-' + myOptions[0][j])<br>
      j += 1<br>    print "</table><br /><br />\n"<br>    i += 1<br>  print '''<br><div align='center'><br><input type='submit' value=' Send ' /><br>
</div><br></form><br></body><br></html>'''<br><br>chooseOptions()<br><br>TIA,<br>V<br>