Author: tmckay
Date: 2012-12-07 21:32:38 +0000 (Fri, 07 Dec 2012)
New Revision: 5568
Modified:
trunk/wooly/python/wooly/__init__.py
trunk/wooly/python/wooly/pages.py
trunk/wooly/python/wooly/server.py
Log:
When an update request is seen for a session with an expired login,
return a response with a Location header requesting a reload. This
will reload the mainpage and Cumin will take the user to the login page
on the way.
BZ873335
Modified: trunk/wooly/python/wooly/__init__.py
===================================================================
--- trunk/wooly/python/wooly/__init__.py 2012-12-07 18:00:35 UTC (rev 5567)
+++ trunk/wooly/python/wooly/__init__.py 2012-12-07 21:32:38 UTC (rev 5568)
@@ -306,13 +306,18 @@
return True
return False
+ def redirect_to_login(self, session):
+ # Redirect to the login page when not logged in.
+ # For some page types (like Update pages) this
+ # is accomplished differently so allow an overload...
+ page = self.app.login_page
+ sess = Session(page)
+ page.origin.set(sess, session.marshal())
+ self.redirect.set(session, sess.marshal())
+
def process(self, session, *args):
if self.check_login and not self.authorized(session):
- # redirect to the login page
- page = self.app.login_page
- sess = Session(page)
- page.origin.set(sess, session.marshal())
- self.redirect.set(session, sess.marshal())
+ self.redirect_to_login(session)
return
if not self.app.authorize_cb(session, self):
Modified: trunk/wooly/python/wooly/pages.py
===================================================================
--- trunk/wooly/python/wooly/pages.py 2012-12-07 18:00:35 UTC (rev 5567)
+++ trunk/wooly/python/wooly/pages.py 2012-12-07 21:32:38 UTC (rev 5568)
@@ -264,6 +264,14 @@
if redirect:
self.redirect.set(session, redirect)
+ def redirect_to_login(self, session):
+ # In the case of an update request when not logged in,
+ # we just want to force a failed update with a Location
+ # header that specifies a reload. This will cause the
+ # client browser to reload the page and Cumin will
+ # redirect to login from there with the correct origin.
+ raise UpdateRedirect("reload")
+
def service(self, session):
self.process(session)
Modified: trunk/wooly/python/wooly/server.py
===================================================================
--- trunk/wooly/python/wooly/server.py 2012-12-07 18:00:35 UTC (rev 5567)
+++ trunk/wooly/python/wooly/server.py 2012-12-07 21:32:38 UTC (rev 5568)
@@ -156,8 +156,11 @@
# process a location change. Javascript code in the
# update handler will look for the header.
status = "200 OK"
- headers.append(("Location",
- page.validate_redirect(session, e.url, env)))
+ if e.url == "reload":
+ headers.append(("Location", "reload"))
+ else:
+ headers.append(("Location",
+ page.validate_redirect(session, e.url, env)))
except:
url = page.redirect_on_exception(session)
if url:
Show replies by date