Browse Source

add debug features

damien 11 years ago
parent
commit
a70829af5b

+ 47 - 0
pboard/pboard/controllers/debug.py View File

@@ -0,0 +1,47 @@
1
+# -*- coding: utf-8 -*-
2
+"""Main Controller"""
3
+
4
+from tg import expose, flash, require, url, lurl, request, redirect, tmpl_context
5
+from tg.i18n import ugettext as _, lazy_ugettext as l_
6
+from tg import predicates
7
+from pboard import model
8
+from pboard.controllers.secure import SecureController
9
+from pboard.model import DBSession, metadata
10
+from tgext.admin.tgadminconfig import TGAdminConfig
11
+from tgext.admin.controller import AdminController
12
+
13
+from pboard.lib.base import BaseController
14
+from pboard.controllers.error import ErrorController
15
+
16
+import pboard.model as pbm
17
+import pboard.controllers as pbc
18
+from pboard.lib import dbapi as pld
19
+from pboard.controllers import api as pbca
20
+
21
+import pboard.model.data as pbmd
22
+
23
+__all__ = ['DebugController']
24
+
25
+
26
+class DebugController(BaseController):
27
+
28
+  allow_only = predicates.in_group('admin',
29
+                              msg=l_('You\'re not allowed to access this page'))
30
+
31
+  @expose('pboard.templates.debug.iconset')
32
+  def iconset(self, **kw):
33
+    """This method showcases how you can use the same controller for a data page and a display page"""
34
+    return dict()
35
+
36
+
37
+  @expose('pboard.templates.debug.environ')
38
+  def environ(self, **kw):
39
+    """This method showcases TG's access to the wsgi environment."""
40
+    return dict(environment=request.environ)
41
+
42
+
43
+  @expose('pboard.templates.debug.identity')
44
+  def identity(self, **kw):
45
+    """This method showcases TG's access to the wsgi environment."""
46
+    return dict(identity=request.identity)
47
+

+ 0 - 0
pboard/pboard/templates/debug/__init__.py View File


+ 23 - 0
pboard/pboard/templates/debug/environ.mak View File

@@ -0,0 +1,23 @@
1
+<%inherit file="local:templates.master"/>
2
+
3
+<%def name="title()">
4
+  debug: environment object
5
+</%def>
6
+
7
+<h2>The WSGI nature of the framework</h2>
8
+  <p>In this page you can see all the WSGI variables your request object has, 
9
+     the ones in capital letters are required by the spec, then a sorted by
10
+     component list of variables provided by the Components, and at last
11
+     the "wsgi." namespace with very useful information about your WSGI Server</p>
12
+  <p>The keys in the environment are: 
13
+  <table class="table">
14
+      %for key in sorted(environment):
15
+      <tr>
16
+          <td>${key}</td>
17
+          <td>${environment[key]}</td>
18
+      </tr>
19
+      %endfor
20
+  </table>
21
+
22
+  </p>
23
+

+ 16 - 0
pboard/pboard/templates/debug/identity.mak View File

@@ -0,0 +1,16 @@
1
+<%inherit file="local:templates.master"/>
2
+
3
+<%def name="title()">
4
+  Learning TurboGears 2.3: Information about TG and WSGI
5
+</%def>
6
+
7
+<h2>Identity object</h2>
8
+  <table class="table">
9
+      %for key in sorted(identity):
10
+      <tr>
11
+          <td>${key}</td>
12
+          <td>${identity[key]}</td>
13
+      </tr>
14
+      %endfor
15
+  </table>
16
+