Permalink
Browse files

rudimentary introspection ui (visit _debug_toolbar/introspection)

  • Loading branch information...
1 parent 720f475 commit 710322505d04f0db236f96146e5fa6c1591baed0 @mcdonc mcdonc committed Nov 24, 2011
@@ -64,4 +64,6 @@ def includeme(config):
'/_debug_toolbar/sqlalchemy/sql_select')
config.add_route('debugtoolbar.sql_explain',
'/_debug_toolbar/sqlalchemy/sql_explain')
+ config.add_route('debugtoolbar.introspection_index',
+ '/_debug_toolbar/introspection')
config.scan('pyramid_debugtoolbar.views')
@@ -0,0 +1,44 @@
+body, input { font-family: sans-serif; color: #000; text-align: left;
+ line-height: 1.2em;
+ margin: 1em; padding: 0;
+ font-size: 15px; }
+h1, h2, h3 { font-family: sans-serif; font-weight: normal; }
+
+a:hover { color: #db7028; }
+pre, code, table.source,
+h1 { font-size: 36px; margin: 0 0 0.3em 0; }
+div.detail p { margin: 0 0 8px 13px; font-size: 14px; }
+div.explanation { margin: 20px 13px; font-size: 15px; color: #555; }
+div.footer { font-size: 13px; text-align: right; margin: 30px 0;
+ color: #999999; }
+
+h2 { font-size: 16px; margin: 1.3em 0 0.0 0; padding: 9px;
+ background: #F98131 url(../img/headerbg.png) repeat-x 0 0; color: #000000; }
+h2 em, h3 em { font-style: normal; color: #ffffff; font-weight: normal; }
+
+div.plain { border: 1px solid #ddd; margin: 0 0 1em 0; padding: 10px; }
+div.plain p { margin: 0; }
+div.plain textarea,
+div.plain pre { margin: 10px 0 0 0; padding: 4px;
+ background-color: #eeeeee; border: 1px solid #dddddd; }
+div.plain textarea { width: 99%; height: 300px; }
+div.traceback pre:hover { background-color: #eeeeee; color: black; cursor: pointer; }
+div.traceback blockquote { margin: 1em 0 0 0; padding: 0; }
+div.traceback img { float: right; padding: 2px; margin: -3px 2px 0 0; display: none; }
+div.traceback img:hover { background-color: #ddd; cursor: pointer;
+ border-color: #eeeeee; }
+div.traceback pre:hover img { display: block; }
+div.traceback cite.filename { font-style: normal; color: #666666; }
+
+span.string { color: #30799B; }
+span.number { color: #9C1A1C; }
+span.help { color: #3A7734; }
+span.object { color: #485F6E; }
+span.extended { opacity: 0.5; }
+span.extended:hover { opacity: 1; }
+a.toggle { text-decoration: none; background-repeat: no-repeat;
+ background-position: center center;
+ background-image: url(../img/more.png); }
+a.toggle:hover { background-color: #444; }
+a.open { background-image: url(../img/less.png); }
+
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+ <head>
+ <title>Pyramid Debug Toolbar Introspector</title>
+ <link rel="stylesheet" href="${static_path}css/introspection.css"
+ type="text/css">
+ </head>
+ <body>
+ <h1>Pyramid Configuration Introspection</h1>
+ <table>
+ % for category_name, entries in categorized:
+ <th><h2>${category_name.capitalize()}</h2></th>
+ % for entry in entries:
+ <tr>
+ <td>
+ <h3><a name="${entry['introspectable'].category_name}${entry['introspectable'].discriminator_hash}">${entry['introspectable'].type_name} ${entry['introspectable'].title}</a></h3>
+ <dl>
+ % for k, v in sorted(entry['introspectable'].items()):
+ % if v:
+ <dt>${k}</dt><dd>${debug_repr(v)|n}</dd>
+ % endif
+ % endfor
+ </dl>
+ % if entry['related']:
+ <h4>References</h4>
+ <ul>
+ % for ref in entry['related']:
+ <li>
+ <h5><a href="#${ref.category_name}${ref.discriminator_hash}">${ref.type_name} ${ref.title}</a></h5>
+ </li>
+ % endfor
+ </ul>
+ % endif
+ </td>
+ </tr>
+ % endfor
+ % endfor
+ </table>
+</body>
+</html>
@@ -11,6 +11,7 @@
from pyramid_debugtoolbar.utils import STATIC_PATH
from pyramid_debugtoolbar.utils import ROOT_ROUTE_NAME
from pyramid_debugtoolbar.utils import format_sql
+from pyramid_debugtoolbar.repr import debug_repr
class ExceptionDebugView(object):
def __init__(self, request):
@@ -161,3 +162,13 @@ def sql_explain(self):
'str': str,
'duration': float(self.request.params['duration']),
}
+
+@view_config(route_name='debugtoolbar.introspection_index',
+ renderer='pyramid_debugtoolbar:templates/introspection_index.mako')
+def introspection_index(request):
+ introspector = request.registry.introspector
+ categorized = introspector.categorized()
+ static_path = request.static_url(STATIC_PATH)
+ return {'categorized':categorized, 'debug_repr':debug_repr,
+ 'static_path':static_path}
+

0 comments on commit 7103225

Please sign in to comment.