Author: tmckay
Date: 2012-02-09 21:04:31 +0000 (Thu, 09 Feb 2012)
New Revision: 5211
Modified:
trunk/cumin/python/cumin/widgets.py
trunk/wooly/python/wooly/__init__.py
trunk/wooly/python/wooly/server.py
Log:
On page exceptions from missing objects, redirect to the main page with
a notice instead of using the not_found_tmpl
Modified: trunk/cumin/python/cumin/widgets.py
===================================================================
--- trunk/cumin/python/cumin/widgets.py 2012-02-09 19:53:24 UTC (rev 5210)
+++ trunk/cumin/python/cumin/widgets.py 2012-02-09 21:04:31 UTC (rev 5211)
@@ -1254,6 +1254,13 @@
return False
+ def redirect_on_exception(self, session, e):
+ # If we have an exception from a missing object, redirect to the
+ # main page with a notice instead of using the not_found_tmpl below
+ if type(e) is RosemaryNotFound:
+ session.add_notice("An object being displayed became unavailable")
+ return "index.html"
+
def render_error(self, session):
cls, value, traceback = sys.exc_info()
@@ -1621,4 +1628,4 @@
def render_listcontainer_height(self, session):
return "%dpx" % self.listcontainer_height
-
\ No newline at end of file
+
Modified: trunk/wooly/python/wooly/__init__.py
===================================================================
--- trunk/wooly/python/wooly/__init__.py 2012-02-09 19:53:24 UTC (rev 5210)
+++ trunk/wooly/python/wooly/__init__.py 2012-02-09 21:04:31 UTC (rev 5211)
@@ -482,6 +482,9 @@
return self.render(session)
+ def redirect_on_exception(self, session, e):
+ return None
+
def service_error(self, session):
self.error.set(session, PageError(self, session))
Modified: trunk/wooly/python/wooly/server.py
===================================================================
--- trunk/wooly/python/wooly/server.py 2012-02-09 19:53:24 UTC (rev 5210)
+++ trunk/wooly/python/wooly/server.py 2012-02-09 21:04:31 UTC (rev 5211)
@@ -132,9 +132,14 @@
# update handler will look for the header.
status = "200 OK"
headers.append(("Location", e.url))
- except:
- content = page.service_error(session)
- status = "500 Internal Error"
+ except Exception as e:
+ url = page.redirect_on_exception(session, e)
+ if url:
+ status = "303 See Other"
+ headers.append(("Location", url))
+ else:
+ content = page.service_error(session)
+ status = "500 Internal Error"
else:
status = "304 Not Modified"
Show replies by date