Custom Classes?

Victor Subervi victorsubervi at gmail.com
Fri May 2 09:38:34 EDT 2008


Thank you for your patience. I apologize for so many errors. Also,
apparently your email client renders those double-spaces whereas mine does
not. Hopefully the below is better:

#!/usr/bin/python

import MySQLdb
import sys,os
sys.path.append(os.getcwd())
from login import login
user, passwd, db, host = login()

pic = "pic1"
w = 20
x = 0
d = 6
y = 1
getpic = "getpic" + str(w) + ".py"
try:
  os.remove(getpic)
except:
  pass
code = """
#!/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:'pic1_thumb',3:'pic2',4:'pic2_thumb',5:'pic3',6:'pic3_thumb',7:'pic4',8:'pic4_thumb',\
9:'pic5',10:'pic5_thumb',11:'pic6',12:'pic6_thumb'}
pic = pics[x]
db = MySQLdb.connect(host, user, passwd, db)
cursor= db.cursor()
sql = "select %s from products where id='%s';" % (pic, str(picid))
cursor.execute(sql)
content = cursor.fetchall()[0][0].tostring()
cursor.close()
print 'Content-Type: image/jpeg'
print
print content
"""
script = open(getpic, "w")
script.write(code)
# print '<td><input type="hidden" name="%s" value="%s" />' % (str(x),  pic)
# print '<img src="%s?id=%d&x=%d"><br /><br /></td>\n' % (getpic, d, y)
print '<img src="getpic20.py?id=6&x=1">\n'



Now, on those last 3 lines, I am having trouble with this error being thrown
that I don´t understand:
ValueError: unpack list of wrong size
If I surf to the given url, the image appears! So what gives?? Furthermore,
the code works just fine from where it was lifted.
TIA,
Victor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080502/ffdb5112/attachment-0001.html>


More information about the Python-list mailing list