Custom Classes?

Victor Subervi victorsubervi at gmail.com
Thu May 8 11:33:55 EDT 2008


Okay, trying this again with everything working and no ValueError or any
other errors, here we go:

Load this code. Unless you use a similar login() script, you will want to
edit your own values into the user, passwd, db and host:

#!/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)
script.close()



and then surf to:
http://whatever.url/getpic20.py?id=6&x=1


Also, please re-send the link on how to post good questions to the list. I
cannot find it.
TIA,
Victor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080508/d5a09217/attachment-0001.html>


More information about the Python-list mailing list