1.70.1 is OUT

7 views
Skip to first unread message

mdipierro

unread,
Oct 30, 2009, 7:24:37 PM10/30/09
to web2py-users
It fixes some problems introduced by new features in 1.69.1.

It also includes:
- db(...).select().as_dict()
- Experimental distributed transactions with mysql, postgresql and
firebird
- Improved validators
- ability to call wsgi apps from actions

def index():
return somewsgiapp
(request.wsgi.environ,request.wsgi.start_response)

and to apply wsgi middleware to normal web2py actions

@request.wsgi.middleware(somewsgimiddleware,someother)
def index(): return 'hello world'

Please report any error.

Thanks to Mr Freeze, Thadeus and Jonathan for help.

Happy Halloween to everybody.

Massimo

hcvst

unread,
Oct 31, 2009, 10:32:29 AM10/31/09
to web2py-users
Hi Massimo,

thanks, this makes wsgi a lot easier - there are a few issues however:

1. environ['wsgi.input'] does not seem to exist - there is however
request.env.wsgi_input.
2. Not sure what the wsgi spec says but one has to call seek(0) on
wsgi_input to 'rewind' the buffer when
using Google's webapp for example as Google does not call getvalue()
but read() to get the buffer contents.
3. The lamda your start_response returns also appears to write to
response.body - Again I am not sure
what the wsgi specs say but usually the call to app(env,
start_response) returns a generator one calls to
get the contents. Google's webapp works nicely with the
response.body.write method though.

HC

mdipierro

unread,
Oct 31, 2009, 12:41:36 PM10/31/09
to web2py-users
request.env is the web2py environment

request.wsgi.environ is the environment you want (created by web2py
for your app). It has wsgi.input.

villas

unread,
Oct 31, 2009, 2:09:57 PM10/31/09
to web2py-users
Do you need to change the subject header to 171.1 ??

hcvst

unread,
Oct 31, 2009, 2:22:57 PM10/31/09
to web2py-users
Hi Massimo,

I am running Version 1.71.0 (2009-10-31 01:13:28).
wsgi.environ does not have wsgi.input (for get or post)
I checked locally and GAE does not find it either.
I currenty have to add it:
request.wsgi.environ['wsgi.input'] = request.env.wsgi_input

HC

mdipierro

unread,
Oct 31, 2009, 2:37:23 PM10/31/09
to web2py-users
It should be

request.wsgi.environ['wsgi.input'] = request.body

can you check in gluon main.py should should have this line

request.wsgi.environ = environ_aux(environ,request)

and environ_aux also on main.py defines wsgi.input

mr.freeze

unread,
Oct 31, 2009, 3:04:22 PM10/31/09
to web2py-users
It's there.

...line 248....
def environ_aux(environ,request):
new_environ = copy.copy(environ)
new_environ['wsgi.input']=request.body
new_environ['wsgi.version']=1
return new_environ
.....
...line 300...
try:
try:
....
request.wsgi.environ = environ_aux(environ,request)

hcvst

unread,
Oct 31, 2009, 5:53:53 PM10/31/09
to web2py-users
line 250: new_environ['wsgi.input']=request.body

But: request.body is None at this stage

Moving the wsgi section in main.py's wsgibase() further down (above
the load cookies),
seems to work for me, but please someone that knows the code have a
look.
Also, this might be a good place to seek(0) the wsgi.input
# ##################################################
# expose wsgi hooks for convenience
# ##################################################

request.wsgi.environ = environ_aux(environ,request)
request.wsgi.start_response = lambda status='200', headers=[], \
exec_info=None, response=response: \
start_response_aux(status, headers, exec_info, response)
request.wsgi.middleware = lambda *a: middleware_aux
(request,response,*a)

# ##################################################
# load cookies
# ##################################################


HC

hcvst

unread,
Oct 31, 2009, 6:15:36 PM10/31/09
to web2py-users
Note - seek(0) is not required.

mdipierro

unread,
Nov 1, 2009, 12:42:30 AM11/1/09
to web2py-users
Good points! Uploading to trunk in 5 minutes.
Reply all
Reply to author
Forward
0 new messages