Yes it is. I have had it print to screen already, and there is data in the database. V
On Wed, Oct 7, 2009 at 10:03 AM, Rami Chowdhury <rami.chowdh...@gmail.com>wrote: > On Wed, 07 Oct 2009 06:37:08 -0700, Victor Subervi < > victorsube...@gmail.com> wrote: > > I took out the line in question (with text/html). Now it prints to screen >> the url. It did that before. Strange. Any other ideas? >> TIA, >> V >> > > Looking at the output, it seems the reason for this (for me) is that > Firefox can't find the image or any alt text for it, so it's just using the > image URL. Are you certain the image data (i.e. the 'content' string) is > correct, and being encoded correctly in the output? > > > >> On Tue, Oct 6, 2009 at 3:40 PM, Rami Chowdhury <rami.chowdh...@gmail.com >> >wrote: >> >> On Tue, 06 Oct 2009 13:26:19 -0700, Victor Subervi < >>> victorsube...@gmail.com> wrote: >>> >>> The code in question is generated automatically from another script. I >>> >>>> took >>>> your idea of the \r\n\r\n and added triple quoting and now it prints out >>>> this: >>>> >>>> #!/usr/local/bin/python >>>> import cgitb; cgitb.enable() >>>> import MySQLdb >>>> import cgi >>>> import sys,os >>>> sys.path.append(os.getcwd()) >>>> from login import login >>>> user, passwd, db, host = login() >>>> form = cgi.FieldStorage() >>>> picid = int(form['id'].value) >>>> x = int(form['x'].value) >>>> pics = {1:'pic1',2:'pic2',3:'pic3',4:'pic4',5:'pic5',6:'pic6'} >>>> pic = pics[x] >>>> print '''Content-Type: text/html >>>> >>>> ''' >>>> db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) >>>> cursor= db.cursor() >>>> sql = "select " + pic + " from products where id='" + str(picid) + "';" >>>> cursor.execute(sql) >>>> content = cursor.fetchall()[0][0].tostring() >>>> cursor.close() >>>> print '''Content-Type: image/jpeg >>>> >>>> ''' >>>> print >>>> print content >>>> >>>> >>>> To answer your questions, I have no idea what eNom has done to their >>>> servers, which is where the other site was hosted (never went live), but >>>> am >>>> in the process of building on DreamHost, who seems to be a FAR better >>>> service than eNom, whom I actually had to report to the BBB and they >>>> never >>>> fixed or acknowledged very obvious problems. At any rate, the above code >>>> gets the browser to print out all the binary "garbage" that should >>>> translate >>>> into an image (you can look: >>>> http://13gems.com/stxresort/cart/getpic1.py?id=1&x=1 ). Any more ideas >>>> would >>>> be helpful. >>>> >>>> >>> Going to that URL, my browser now tries to render an HTML page, and I can >>> now see the 'Content-Type: image/jpeg' string being printed into the HTML >>> source. Have you tried removing the 'Content-Type: text/html' header, >>> with >>> the new triple-quoted syntax? >>> >>> >>> -- >>> Rami Chowdhury >>> "Never attribute to malice that which can be attributed to stupidity" -- >>> Hanlon's Razor >>> 408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD) >>> >>> > > > -- > Rami Chowdhury > "Never attribute to malice that which can be attributed to stupidity" -- > Hanlon's Razor > 408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD) >
-- http://mail.python.org/mailman/listinfo/python-list