2009/1/21 gert <[email protected]>:
>
> The John Machin decode('latin1') solution from comp.lang.python

Yes, was what I was going to suggest,  but more complicated than that.

Because you have now read the whole of wsgi.input into memory, memory
usage can blow out now for large file uploads. What you really want is
a wrapper around wsgi.input which mirrors normal functions exposed by
it and as required by WSGI specification, which for each call to it
will read only the amount requested and convert just that amount of
data to latin unicode string.

This way FieldStorage class can work more efficiently as far as amount
of memory used.

Sorry, have no time to provide actual code example.

Graham

> 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