From 70a1fbfd41851fca3727dc557caf6edbed0909ac Mon Sep 17 00:00:00 2001 From: mdipierro Date: Thu, 29 Aug 2013 08:22:35 -0500 Subject: [PATCH] bypass all session logic when application does not exist, and close files --- VERSION | 2 +- gluon/main.py | 79 +++++++++++++++++++++++++-------------------------- 2 files changed, 40 insertions(+), 41 deletions(-) diff --git a/VERSION b/VERSION index 2268dffd..cc808f0d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.6.0-development+timestamp.2013.08.29.08.09.00 +Version 2.6.0-development+timestamp.2013.08.29.08.21.46 diff --git a/gluon/main.py b/gluon/main.py index 576bb8be..21669463 100644 --- a/gluon/main.py +++ b/gluon/main.py @@ -455,58 +455,57 @@ def wsgibase(environ, responder): except HTTP, http_response: - # if this is a static file - # or the application does not exist - if static_file or not hasattr(current,'request'): + if static_file: return http_response.to(responder, env=env) if request.body: request.body.close() - # ################################################## - # on success, try store session in database - # ################################################## - session._try_store_in_db(request, response) + if hasattr(current,'request'): - # ################################################## - # on success, commit database - # ################################################## + # ################################################## + # on success, try store session in database + # ################################################## + session._try_store_in_db(request, response) - if response.do_not_commit is True: - BaseAdapter.close_all_instances(None) - # elif response._custom_commit: - # response._custom_commit() - elif response.custom_commit: - BaseAdapter.close_all_instances(response.custom_commit) - else: - BaseAdapter.close_all_instances('commit') + # ################################################## + # on success, commit database + # ################################################## + + if response.do_not_commit is True: + BaseAdapter.close_all_instances(None) + elif response.custom_commit: + BaseAdapter.close_all_instances(response.custom_commit) + else: + BaseAdapter.close_all_instances('commit') - # ################################################## - # if session not in db try store session on filesystem - # this must be done after trying to commit database! - # ################################################## + # ################################################## + # if session not in db try store session on filesystem + # this must be done after trying to commit database! + # ################################################## - session._try_store_in_cookie_or_file(request, response) + session._try_store_in_cookie_or_file(request, response) - if request.cid: - if response.flash: - http_response.headers['web2py-component-flash'] = \ - urllib2.quote(xmlescape(response.flash)\ - .replace('\n','')) - if response.js: - http_response.headers['web2py-component-command'] = \ - urllib2.quote(response.js.replace('\n','')) + if request.cid: + if response.flash: + http_response.headers['web2py-component-flash'] = \ + urllib2.quote(xmlescape(response.flash)\ + .replace('\n','')) + if response.js: + http_response.headers['web2py-component-command'] = \ + urllib2.quote(response.js.replace('\n','')) + + # ################################################## + # store cookies in headers + # ################################################## - # ################################################## - # store cookies in headers - # ################################################## + rcookies = response.cookies + if session._forget and response.session_id_name in rcookies: + del rcookies[response.session_id_name] + elif session._secure: + rcookies[response.session_id_name]['secure'] = True + http_response.cookies2headers(rcookies) - rcookies = response.cookies - if session._forget and response.session_id_name in rcookies: - del rcookies[response.session_id_name] - elif session._secure: - rcookies[response.session_id_name]['secure'] = True - http_response.cookies2headers(rcookies) ticket = None except RestrictedError, e: