<div class="gmail_quote">On Thu, Apr 3, 2008 at 9:34 AM, Gabriel Genellina <<a href="mailto:gagsl-py2@yahoo.com.ar">gagsl-py2@yahoo.com.ar</a>> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">En Thu, 03 Apr 2008 09:43:57 -0300, Victor Subervi<br><<a href="mailto:victorsubervi@gmail.com">victorsubervi@gmail.com</a>> escribió:<br>
<br>>> Steve Holden wrote:<br>>> Define "no longer works".<br>> Sorry. Throws HTTP 200 error.<br><br>HTTP 200 means OK.</blockquote>
<div> </div>
<div>Yes. But there is an error somewhere, because it doesn´t run all the code. For example, I have to manually drop the table.</div>
<div> </div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><span id=""></span><br><br>>> > The same remarks I've posted earlier apply here.<br>> Must have missed those. Yes, the code works fine. Repeatedly.<br>
<br><a href="http://groups.google.com/group/comp.lang.python/browse_thread/thread/b732eee4e91b1868/" target="_blank">http://groups.google.com/group/comp.lang.python/browse_thread/thread/b732eee4e91b1868/</a></blockquote>
<div> </div>
<div>Thank you. I believe you mean by bound, something like this, right?</div>
<div>binary(picdata)</div>
<div>I am now doing that, if I am not mistaken.</div>
<div> </div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">display or *log* errors...</blockquote>
<div> </div>
<div>Yeah. There are always errors...</div>
<div> </div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">*post*? This is the server response. Return either text *or* an image (the<br>text may be an html referencing the image)</blockquote>

<div> </div>
<div>Yes, post. But what do I write instead of this?</div>
<div>print 'Content-Type: image/jpeg\r\n'</div>
<div> </div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Test it locally (just the database thing, no web), test the cgi script<br>without database interaction, only then join the two.</blockquote>

<div> </div>
<div>Okay, but how do I upload an image into mysql without a script? And once I can do that, everything´s (almost) solved!</div>
<div> </div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">But you can read the server logs at least?</blockquote>
<div> </div>
<div>I am new to Plesk. I discovered I can read logs. More following...</div>
<div> </div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><span id=""></span><br>Your code is throwing exceptions but you're not seeing them. Use the cgitb<br>module <a href="http://docs.python.org/lib/module-cgitb.html" target="_blank">http://docs.python.org/lib/module-cgitb.html</a></blockquote>

<div> </div>
<div>Now here you give me another laugh :) I added this line to the script</div>
<div>import cgitb; cgitb.enable()<br>and suddenly I can take out these junk lines that were throwing the HTTP 200 error:</div>
<div>names = 'aramis', 'athos', 'porthos'<br>data = {}<br>for name in names:<br>  datum = list(name)<br>  datum.sort()<br>  data[name] = cPickle.dumps(datum, 1)<br></div>
<div>Is this some kind of magic wand? :)</div>
<div> </div>
<div>Okay, where I am at now...</div>
<div> </div>
<div>I have a script called start.py which has this code in it:</div>
<div> </div>
<div>import cgitb; cgitb.enable()<br>import MySQLdb<br>import struct<br>import _mysql, sys<br></div>
<div>Lots of imports, just to try things out. Most not needed...</div>
<div> </div>
<div>  col_names = ['id', 'name_en', 'name_es', 'name_it', 'category', 'title_en', 'title_es', 'title_it', \<br>    'description_en', 'description_es', 'description_it', 'price', 'bedrooms', 'bathrooms', 'pic1', 'sort_factor']<br>
</div>
<div>Just notice the pic1 there...</div>
<div>Then I make a nice list of colnames like MySQL wants...</div>
<div> </div>
<div>  col_names_with_commas = ''<br>  for name in col_names:<br>    col_names_with_commas += name + ', '<br>  count = len(col_names_with_commas)-2<br>  col_names_with_commas = col_names_with_commas[0:len(col_names_with_commas)-2]<br>
</div>
<div>All that I have checked, it is good...</div>
<div>Here is the sticky point:</div>
<div> </div>
<div>    for id in ids:<br>      for d in id:<br>        print '<tr>\n'<br>        cursor.execute('select ' + col_names_with_commas + ' from products where id = ' + str(d) + ';')<br>
        col_fields = cursor.fetchall()<br>        i = 0<br>        x = 0<br>        for field in col_fields[0]:<br>          if x == 0:<br>            # This is the ID field<br>            i += 1<br>            check = 'check' + str(i)<br>
            print '<td><input type="checkbox" name="', check, '" value="', field, '" /></td>\n'<br>          if x == 15:<br>            print '<td>', field, '</td>\n'<br>
          else:<br>            print '<td>', field, '</td>\n'<br>          x += 1<br></div>
<div>I have to do both of those for statements. The sticky point is in the last if statement. 15 is the pic1 field. Should I use binary(field) instead? It does not like that. </div>
<div> </div>
<div>I send the whole thing over to another script which has this:</div>
<div> </div>
<div>import cgitb; cgitb.enable()<br>import MySQLdb<br>import cgi<br>import struct<br></div>
<div>Same old same old...</div>
<div>Here´s the sticky part...</div>
<div> </div>
<div>  if what_do == 'insert':<br>    data = ['', '', '', '', '', '', '', '', '', '', '', 0.0, '', '', '', 500]<br>
    the_form(data, what_do)<br>  elif what_do == 'update':<br>    cursor.execute('select * from products where id=' + update_these[0] + ';')<br>    data = cursor.fetchall()<br>    the_form(data[0], what_do)<br>
</div>
<div>And then try to render...</div>
<div> </div>
<div><td><br>1ra Foto Grande:<br></td><td><br><input type='file' name='pic1' value="""<br>  print '"', binary(data[14]), '"'<br>  print """<br>
/><br></div>
<div>I show you both parts, because the Internal Server Error comes from the second page, but the logged error points to the first page. Here is the log record...</div>
<div> </div>
<div>[Thu Apr 03 09:53:33 2008] [error] [client <a href="http://190.166.0.65">190.166.0.65</a>] PythonHandler mod_python.cgihandler: File "/var/www/vhosts/<a href="http://livestocksling.com/httpdocs/test/python/Shop/iud.py">livestocksling.com/httpdocs/test/python/Shop/iud.py</a>", line 210, in the_form\n print '"', binary(data[14]), '"', referer: <a href="http://livestocksling.com/test/python/Shop/start.py">http://livestocksling.com/test/python/Shop/start.py</a> <br>
[Thu Apr 03 09:53:33 2008] [error] [client <a href="http://190.166.0.65">190.166.0.65</a>] PythonHandler mod_python.cgihandler: NameError: global name 'binary' is not defined, referer: <a href="http://livestocksling.com/test/python/Shop/start.py">http://livestocksling.com/test/python/Shop/start.py</a> <br>
</div>
<div>TIA,</div>
<div>Victor</div></div>