eval(WsgiApplication)

Arnaud Delobelle arnodel at googlemail.com
Sat May 2 04:25:47 EDT 2009


gert <gert.cuykens at gmail.com> writes:

> I would like to read the following from a text file
>
> from json import loads
> from gert.db import Db
> def application(environ, response):
>     v = loads(environ['wsgi.input'].read(int(environ
> ['CONTENT_LENGTH'])).decode('utf-8'))
>     db = Db()
>     db.execute('UPDATE votes SET count=count+1 WHERE vid=?',(v
> ['vid'],))
>     db.execute('SELECT * FROM votes')
>     j = '{"rec":'+db.json()+',\n'
>     j+= ' "des":'+db.jdes()+'}'
>     j = j.encode('utf-8')
>     response('200 OK', [('Content-type', 'text/
> javascript;charset=utf-8'), ('Content-Length', str(len(j)))])
>     return [j]
>
> execute it, and wrap a new function name around it for example
>
> def wrapper(environ, response):
>      exec(file)
>      return application(environ, response)
>
> How do I do this in python3?

What's wrong with importing it?

-- 
Arnaud



More information about the Python-list mailing list