Added error handling and 'About' page
authorAaron Bentley <abentley@panoramicfeedback.com>
Fri, 23 Dec 2005 17:40:43 +0000 (12:40 -0500)
committerAaron Bentley <abentley@panoramicfeedback.com>
Fri, 23 Dec 2005 17:40:43 +0000 (12:40 -0500)
beweb/beweb/controllers.py
beweb/beweb/static/css/style.css
beweb/beweb/templates/about.kid [new file with mode: 0644]
beweb/beweb/templates/error.kid [new file with mode: 0644]
beweb/beweb/templates/master.kid

index 564c43be5c8b0a7845c808af42d059a440b3e27a..b0f13db5d2820cfef929f791e46ce9bc6515a648 100644 (file)
@@ -1,7 +1,8 @@
 import turbogears
 from turbogears import controllers
 import cherrypy
-from libbe.bugdir import tree_root, cmp_severity, new_bug, new_comment
+from libbe.bugdir import (tree_root, cmp_severity, new_bug, new_comment, 
+                          NoRootEntry)
 from libbe import names
 from config import projects
 from prest import PrestHandler, provide_action
@@ -136,6 +137,37 @@ class Root(controllers.Root):
     @turbogears.expose()
     def index(self):
         raise cherrypy.HTTPRedirect(project_url()) 
+
+    @turbogears.expose('beweb.templates.about')
+    def about(self, *paths, **kwargs):
+        return {}
+
     @turbogears.expose()
     def default(self, *args, **kwargs):
         return self.prest.default(*args, **kwargs)
+
+    def _cpOnError(self):
+        import traceback, StringIO
+        bodyFile = StringIO.StringIO()
+        traceback.print_exc(file = bodyFile)
+        trace_text = bodyFile.getvalue()
+        try:
+            raise
+        except cherrypy.NotFound:
+            self.handle_error('Not Found', str(e), trace_text, '404 Not Found')
+
+        except NoRootEntry, e:
+            self.handle_error('Project Misconfiguration', str(e), trace_text)
+
+        except Exception, e:
+            self.handle_error('Internal server error', str(e), trace_text)
+
+    def handle_error(self, heading, body, traceback=None, 
+                     status='500 Internal Server Error'):
+        cherrypy.response.headerMap['Status'] = status 
+        cherrypy.response.body = [self.errorpage(heading, body, traceback)]
+        
+
+    @turbogears.expose(html='beweb.templates.error')
+    def errorpage(self, heading, body, traceback):
+        return {'heading': heading, 'body': body, 'traceback': traceback}
index 03c2ca487ef293fa6d0e495867e0c5cb2f1e746c..160beff15e1987fa68ed7ba3938d07b69a0d86d0 100644 (file)
@@ -71,6 +71,19 @@ body
     background-repeat: no-repeat;
     background-color: #ff0;
 }
+#header ul.navoption
+{
+    display: block;
+    float: right;
+    margin: 0;
+    padding-right: 30px;
+}
+#header li
+{
+    display: inline;
+    margin:0;
+    padding:0;
+}
 table.insetbox
 {
   margin-top: 0.5em;
@@ -81,3 +94,7 @@ table.insetbox
   margin: 0;
   padding: 0;
 }
+pre.traceback
+{
+  font-family: Verdana, Ariel, Helvetica, sanserif;
+}
diff --git a/beweb/beweb/templates/about.kid b/beweb/beweb/templates/about.kid
new file mode 100644 (file)
index 0000000..93aad7a
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"
+    py:extends="'master.kid'">
+<head>
+    <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
+    <title>About Bugs Everywhere</title>
+</head>
+
+<body>
+<h1>About Bugs Everywhere</h1>
+<p>Bug Everywhere was designed by Aaron Bentley and implemented by Aaron
+    Bentley and Oleg Romanyshyn.
+</p>
+<p>
+    Some of its development was sponsored by 
+    <a href="http://panoramicfeedback.com/">Panoramic Feedback</a>
+</p>
+<a href="/">Project List</a>
+</body>
+</html>
diff --git a/beweb/beweb/templates/error.kid b/beweb/beweb/templates/error.kid
new file mode 100644 (file)
index 0000000..bc55615
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"
+    py:extends="'master.kid'">
+<head>
+    <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
+    <title>BE Error: ${heading}</title>
+</head>
+
+<body>
+<h1 py:content="heading">Error heading</h1>
+<div py:replace="body" >Error Body</div>
+<pre py:content="traceback" class="traceback">Traceback</pre>
+</body>
+</html>
index f6f54b1f4d2c858261524df55d44ce015b8d4e6c..ea8f57a1ec584441350f0e939aaf4af203953e35 100644 (file)
 </head>
 
 <body py:match="item.tag=='{http://www.w3.org/1999/xhtml}body'">
-<div id="header">b u g s   e v r y w h e r e</div> 
+<div id="header"><div style="float: left">b u g s   e v r y w h e r e</div><ul class="navoption"><li><a href="/about/">About</a></li></ul>&#160;</div> 
     <div py:if="tg_flash" class="flash" py:content="tg_flash"></div>
     
     <div py:replace="item[:]"/>
 </body>
-<table py:match="item.tag=='{http://www.w3.org/1999/xhtml}insetbox'" cellspacing="0" cellpadding="0" border="0" class="insetbox">
+<table py:match="item.tag=='{http://www.w3.org/1999/xhtml}insetbox'" ellspacing="0" cellpadding="0" border="0" class="insetbox">
 <tr height="19"><td background="/static/images/is-tl.png" width="19"/>
     <td background="/static/images/is-t.png" />
     <td background="/static/images/is-tr.png" width="11"></td>