<div class="gmail_quote">On Thu, Dec 3, 2009 at 10:53 AM, Carsten Haese <span dir="ltr"><<a href="mailto:carsten.haese@gmail.com">carsten.haese@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="im">Victor Subervi wrote:<br>
> In order to help you diagnose the problem, we need to see the *exact*<br>
> code you're running, we need to see the *exact* inputs going into it,<br>
> and we need to see the *exact* output coming out of it.<br>
><br>
><br>
> Let's see your answers and see if you're right that the above output<br>
> helps you arrive at the correct conclusion.<br>
<br>
</div>No, it doesn't, because you've only provided one third of what I asked<br>
for. I also asked for the code and the inputs that go into it.<br></blockquote><div><br>I provided those earlier. To be sure I don't miss anything that may be important, here is the entire code for chooseOptions.py, the referrer. What I consider to be the important code is between the <SNIPPETS>:<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><br><SNIPPET><br>
<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>
<br></SNIPPET><br>
<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>
<br><SNIPPET><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><br><SNIPPET><br>
<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><br>Here is the pared-down code (to the "products") from options.py:<br><br>def products(which='', specificTables=[]):<br> code = []<br> names = []<br> meanings = []<br> code.append(['Extra-small', 'Small', 'Medium', 'Large', 'XLarge', 'XXLarge', 'XXXLarge'])<br>
meanings.append('The standard sizes.')<br> names.append('sizes')<br> if which == 'names':<br> for name in colors('products', 'names'):<br> names.append(name)<br> for meaning in colors('products', 'meanings'):<br>
meanings.append(meaning)<br> return names, meanings<br> elif which == 'specificTables':<br> whichTablesToReturn = []<br> colorsTables, colorsNames = colors('products', 'specificTables', specificTables)<br>
for name in colorsNames:<br> names.append(name)<br> for table in colorsTables:<br> code.append(table)<br> i = 0<br> while i < len(names): # We utilize the name of the table to determine where it is in the code tuple<br>
for table in specificTables:<br> if names[i] == table:<br> whichTablesToReturn.append(i)<br> i += 1<br> returnTheseTables = []<br> for table in whichTablesToReturn:<br> returnTheseTables.append(code[table])<br>
returnTheseNames = []<br> for table in whichTablesToReturn:<br> returnTheseNames.append(names[table])<br> i = 0<br> all = ''<br> table = ''<br> while i < len(returnTheseNames):<br>
table += "<table border='1'>\n <tr>\n <td colspan='16' align='center'><b>%s</b></td>\n </tr>" % returnTheseNames[i]<br> j = 0<br> for elt in code[i]:<br>
if (j + 8) % 8 == 0:<br> table += ' <tr>\n'<br> table += ' <td>%s</td>\n' % code[i][j]<br> table += " <td><input type='checkbox' name='%s' value='%s' /></td>" % (returnTheseNames[i], returnTheseTables[i][j])<br>
if (j + 1) % 8 == 0:<br> table += ' </tr>\n'<br> j += 1<br> if table[-6:] != '</tr>\n':<br> table += ' </tr>\n'<br> table += '</table>\n'<br>
all += table + '<br /><br />'<br> i += 1<br> print all<br> else:<br> i = 0<br> all = ''<br> if which != '': # I place a dummy value in here to get what I want<br>
ourCode = []<br> ourMeanings = []<br> ourNames = specificTables<br> i = 0<br> for name in names:<br> for check in ourNames:<br> if name == check:<br> ourCode.append(code[i])<br>
ourMeanings.append(meanings[i])<br> i += 1<br> else:<br> ourCode = code<br> ourMeanings = meanings<br> ourNames = names<br> ourColors = []<br> i = 0<br> while i < len(ourNames):<br>
if ourNames[i] in names:<br> table = '<i>%s</i>\n' % ourMeanings[i]<br> table += "<table border='1'>\n <tr>\n <td colspan='16' align='center'><b>%s</b></td>\n </tr>" % ourNames[i]<br>
j = 0<br> for elt in ourCode[i]:<br> if (j + 8) % 8 == 0:<br> table += ' <tr>\n'<br> table += ' <td>%s</td>\n' % ourCode[i][j]<br> table += " <td><input type='checkbox' name='%s' value='%s' /></td>" % (ourNames[i], ourCode[i][j])<br>
if (j + 1) % 8 == 0:<br> table += ' </tr>\n'<br> j += 1<br> if table[-6:] != '</tr>\n':<br> table += ' </tr>\n'<br> table += '</table>\n'<br>
all += table + '<br /><br />'<br> else: # This must be a color option<br> ourColors.append(ourNames[i])<br> i += 1<br> all += colors('products', 'junk', ourColors)<br>
return all<br><br><br>Here is the chooseOptions2.py, with <SNIPPET>:<br><br>#! /usr/bin/python<br><br>import cgitb; cgitb.enable()<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 optionsPrintout(table):<br> form = cgi.FieldStorage()<br> fn = getattr(options, table)<br> ourOptionsNames = []<br> optionsNames, doNotUse = fn('names')<br>
<br><SNIPPET><br><br> for name in optionsNames:<br> check = form.getfirst(table + '-' + name, '')<br> if check != '':<br> ourOptionsNames.append(name)<br> try:<br> return fn('junk', ourOptionsNames)<br>
except:<br> pass<br><br>
<SNIPPET><br>
<br>
<br>def chooseOptions2():<br> print '''Content-Type: text/html\r\n<br><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><br><html><br><form action='chooseOptions3.py' method='post'><br>
'''<br> print '<h2>Which options shall we associate with the items in each shop?</h2><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> i = 0<br> for table in storesTables:<br> try:<br>
fn = getattr(options, table) # This is only here to trigger the try statement<br> print "<table border='1' bgcolor='#%s'>\n <tr>\n <td>\n" % bgcolors[i]<br> print '<h1 align="center">%s</h1>' % (table[0].upper() + table[1:])<br>
print optionsPrintout(table)<br> print " </td>\n </tr>\n</table><br /><br />\n"<br> except:<br> # All tables must have the products options in them by defualt<br>
print "<table border='1' bgcolor='#%s'>\n <tr>\n <td>\n" % bgcolors[i]<br> print '<h1 align="center">%s</h1>' % (table[0].upper() + table[1:])<br>
# print optionsPrintout('products')<br> print " </td>\n </tr>\n</table><br /><br />\n"<br> i += 1<br> print '''<br></td></tr></table><br /><br /><br>
<div align='center'><br><input type='submit' value=' Send ' /><br></div><br></body><br></html>'''<br><br>chooseOptions2()<br><br>TIA,<br>V<br></div></div>