The John Machin decode('latin1') solution from comp.lang.python

Victory :)
http://91.121.53.159/appwsgi/www/register/register.htm
http://code.google.com/p/appwsgi/source/browse/trunk

from db import Db
from session import Session
from re import search,match,DOTALL

def application(environ, response):
    db = Db()
    cookie = "SID="+environ['QUERY_STRING']
    session = Session(db,cookie,'guest')
    response('200 OK', [('Content-type', 'text/xml'), ('Set-Cookie',
session.COOKIE)])
    if not session.GID : return []
    s = environ['wsgi.input'].read().decode('latin1')
    b = search(r'boundary=(.*)',environ['CONTENT_TYPE']).group(1)
    p = search(r'Content-Type: application/octet-stream\r\n\r\n(.*)\r
\n--',s,DOTALL).group(1)
    db.execute('UPDATE users SET picture=? WHERE uid=?',(p.encode
('latin1'),session.UID))
    xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    xml+= "<root>"+str(db.ERROR)+"</root>"
    response('200 OK', [('Content-type', 'text/xml')])
    return [xml]


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to