Strange MySQL Problem...

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Apr 3 10:34:13 EDT 2008


En Thu, 03 Apr 2008 09:43:57 -0300, Victor Subervi  
<victorsubervi at gmail.com> escribió:

>> Steve Holden wrote:
>> Define "no longer works".
> Sorry. Throws HTTP 200 error.

HTTP 200 means OK.

>> > The same remarks I've posted earlier apply here.
> Must have missed those. Yes, the code works fine. Repeatedly.

http://groups.google.com/group/comp.lang.python/browse_thread/thread/b732eee4e91b1868/

>>    In general, server side programs should have a try-block
>> wrapped around most of the program, with some code to display or
>> log errors in some useful way.
> Curious. Why? During testing, I understand, but after testing, why?

display or *log* errors...

>> Gabriel Genellina wrote:
>> > print 'Content-Type: image/jpeg\r\n'
>> > print '<html><body>\nHi!\n'
>>
>> Don't you see a conflict among those two lines?
>> (You're a liar: first you promise to send a nice picture and then you  
>> only
>> send a letter!)
> LOL! Okay, make me honest ;) I want to post both text and images. What  
> use?

*post*? This is the server response. Return either text *or* an image (the  
text may be an html referencing the image)

>> > sql = "INSERT INTO justatest VALUES (%s, %s)"
>> > cursor.execute(sql, ('ramis', _mysql.escape_string(f)) )
>>
>> You're using bound parameters now, a good thing. There is no need to
>> escape strings passed as parameters - in fact, it is wrong, as the  
>> adapter
>> will escape the text again.
>> In this case, the column is a BLOB, and you have to use the Binary
>> function: MySQLdb.Binary(f)
>>
>
> Nope. Threw me another HTTP 200.

Again, HTTP 200 means OK. See section 10.2.1 at  
http://www.faqs.org/rfcs/rfc2616.html

> Wrong. I check the mysql and drop the table if the code throws me an HTTP
> 200 error. I have run this code many times now. That is what makes the  
> whole
> thing so ridiculously strange to me. That code snippet, that the script
> insists on, is a relic from the code I tweaked. It was there to make a
> binary, that is all. So why do I still need the darn thing??

Test it locally (just the database thing, no web), test the cgi script  
without database interaction, only then join the two.

>> You have to look at the server error logs, else you're blind fighting.
> I am blind fighting. No longer run my own server, no longer have root
> access.

But you can read the server logs at least?
Your code is throwing exceptions but you're not seeing them. Use the cgitb  
module http://docs.python.org/lib/module-cgitb.html

-- 
Gabriel Genellina




More information about the Python-list mailing list