1 """management and error screens |
1 """management and error screens |
2 |
2 |
3 |
3 |
4 :organization: Logilab |
4 :organization: Logilab |
5 :copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
6 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
7 """ |
7 """ |
8 __docformat__ = "restructuredtext en" |
8 __docformat__ = "restructuredtext en" |
9 |
9 |
10 from time import strftime, localtime |
10 from time import strftime, localtime |
11 |
11 |
12 from logilab.mtconverter import html_escape |
12 from logilab.mtconverter import html_escape |
13 |
13 |
|
14 from cubicweb.selectors import none_rset, match_user_groups |
14 from cubicweb.common.view import StartupView |
15 from cubicweb.common.view import StartupView |
15 |
16 |
16 def dict_to_html(w, dict): |
17 def dict_to_html(w, dict): |
17 # XHTML doesn't allow emtpy <ul> nodes |
18 # XHTML doesn't allow emtpy <ul> nodes |
18 if dict: |
19 if dict: |
19 w(u'<ul>') |
20 w(u'<ul>') |
20 for key in sorted(dict): |
21 for key in sorted(dict): |
21 w(u'<li><span class="label">%s</span>: <span>%s</span></li>' % ( |
22 w(u'<li><span class="label">%s</span>: <span>%s</span></li>' % ( |
22 html_escape(str(key)), html_escape(repr(dict[key])))) |
23 html_escape(str(key)), html_escape(repr(dict[key])))) |
23 w(u'</ul>') |
24 w(u'</ul>') |
|
25 |
24 |
26 |
25 class DebugView(StartupView): |
27 class DebugView(StartupView): |
26 id = 'debug' |
28 id = 'debug' |
|
29 __selectors__ = (none_rset, match_user_groups('managers'),) |
27 title = _('server debug information') |
30 title = _('server debug information') |
28 require_groups = ('managers',) |
|
29 |
31 |
30 def call(self, **kwargs): |
32 def call(self, **kwargs): |
31 """display server information""" |
33 """display server information""" |
32 w = self.w |
34 w = self.w |
33 w(u'<h1>server sessions</h1>') |
35 w(u'<h1>server sessions</h1>') |