Ben Bangert avatar Ben Bangert committed 009c4e2

Better traceback display handling

Comments (0)

Files changed (4)

kai/controllers/tracebacks.py

 from pylons.decorators import jsonify
 
 from kai.lib.base import BaseController, render
-from kai.model import Traceback
+from kai.model import Human, Traceback
 
 log = logging.getLogger(__name__)
 
 class TracebacksController(BaseController):
+    def __before__(self):
+        c.active_tab = 'Tools'
+        c.active_sub = 'Tracebacks'
+    
     @jsonify
     def create(self):
         """Create a new traceback in the system, pegged to the current
         tb.uuid = None
         tb.store(self.db)
         return 'ok'
+    
+    def show(self, id):
+        c.traceback = Traceback.load(self.db, id) or abort(404)
+        if c.traceback.displayname:
+            c.author = Human.load(self.db, c.traceback.human_id)
+        return render('/tracebacks/show.mako')

kai/model/human.py

 import os
+import md5
 import sha
 from datetime import datetime
 
             return True
         else:
             return False
-
+    
+    def email_hash(self):
+        return md5.md5(self.email).hexdigest()
+    
     def generate_token(self):
         """Generate's a token for use either for forgot password or
         email verification"""

kai/public/css/tweaks.css

-/* @override http://localhost:5050/css/tweaks.css */
+/* @override http://localhost.com:5050/css/tweaks.css */
 
 .content h1, .content h2, .content h3, .content h4, .content h5, .content h6 {
     color:#00607b;
     border: none;
     border-bottom: 1px solid #ddd;
 }
-
+
+/* Traceback */
+div.traceback_post.user_post {
+	float: right;
+    width: 200px;
+}
+
+h2.traceback em {
+    color: #888;
+    font-size: 77%;
+}
+
+/* User data */
+
+div.user_post {
+    padding: 4px;
+    margin: 0;
+    font-size: 77%;
+    border: 1px solid #ddd;
+}
+
+
+div.user_post div.user_icon {
+    float: left;
+    padding: 0 6px 0 0;
+}
+
+div.user_post div.username {
+    font-weight: bold;
+}
 
 /* Form errors */
 

kai/templates/tracebacks/show.mako

-<div class=”yui-b”>
-    <h1>Exception ID: ${c.id}</h1>
-    <% date = h.parse_iso_date(c.traceback.created.text) %>
-    <p class="posted">Posted on ${date.strftime('%Y-%m-%d at %H:%M:%S')}</p>
-    <% exc = c.traceback.traceback.exception %>\
-    <div class="details">
-    Exception: <span class="errormsg">${exc.type}: ${exc.value}</span>
+<div class="yui-b content">
+    <% combined_exc = '%s: %s' % (c.traceback.exception_type, c.traceback.exception_value) %>
+    <div class="traceback_post user_post">
+        <div class="user_icon">\
+            % if c.author:
+                <img src="http://www.gravatar.com/avatar/${c.author.email_hash()}?s=30">
+            % else:
+                <img src="http://www.gravatar.com/avatar/3b3be63a4c2a439b013787725dfce802?s=30">
+            % endif
+        </div>
+        <div class="username">${c.author.displayname if c.author else 'Anonymous'}</div>
+        <div class="posted">${format.datetime(c.traceback.created)}</div>
     </div>
+    <h1>${h.link_to(combined_exc, url=url.current())}</h1>
     <h2 class="traceback">Traceback <em>(most recent call last)</em></h2>
     <div class="traceback">
         <ul>
-        % for frame in c.traceback.traceback.stack.iterchildren(tag='frame'):
+        % for frame in c.traceback.frames:
         <li><h4>
             Module <cite>${frame.module}</cite>, line <em>${frame.line}</em>, in \
 <code>${frame.function}</code></h4>
-            % if hasattr(frame, 'operation'):
-            ${highlight(frame.operation.text, py_lexer, html_formatter) | n}\
-            % else:
-            No operation context
-            % endif
+            ${highlight(frame.operation, py_lexer, html_formatter) | n}\
         </li>
         % endfor
         </ul>
-        <blockquote>${exc.type}: ${exc.value}</blockquote>
+        <blockquote>${c.traceback.exception_type}: ${c.traceback.exception_value}</blockquote>
     </div>
     <div class="stats">
         <h2 class="system">System Info</h2>
         <div class="system">
-            <% sysinfo = c.traceback.traceback.sysinfo %>
-            ${sysinfo.language}: ${sysinfo.language.get('version')}
+            ${c.traceback.language}: ${c.traceback.version}
         </div>
         <div class="libraries">
             <h3 class="libraries">Libraries</h3>
-            % for lib in sysinfo.libraries.iterchildren(tag='library'):
+            % for lib in c.traceback.libraries:
             <div class="library">
-                ${lib.get('name')}: <span class="version">${lib.get('version')}</span>
+                ${lib.name}: <span class="version">${lib.version}</span>
             </div>
             % endfor
         </div>
     </div>
-    
 </div>
-<%def name="title()">${parent.title()} - Traceback ${c.id}</%def>\
+<%def name="title()">${parent.title()} - ${_('Traceback %s' % c.traceback.id)}</%def>\
 <%inherit file="../layout.mako" />\
 <%!
 from pygments import highlight
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.