diff -r 785299dfc2c0 -r fccda6dd91bf web/views/debug.py
--- a/web/views/debug.py Fri Feb 26 08:46:27 2010 +0100
+++ b/web/views/debug.py Fri Feb 26 09:54:03 2010 +0100
@@ -25,41 +25,89 @@
w(u'')
-class DebugView(StartupView):
- __regid__ = 'debug'
+
+class ProcessInformationView(StartupView):
+ __regid__ = 'info'
__select__ = none_rset() & match_user_groups('managers')
- title = _('server debug information')
+
+ title = _('server information')
def call(self, **kwargs):
"""display server information"""
+ req = self._cw
+ dtformat = req.property_value('ui.datetime-format')
+ _ = req._
w = self.w
- w(u'
server sessions
')
- sessions = self._cw.cnx._repo._sessions.items()
+ # generic instance information
+ w(u'%s
' % _('Instance'))
+ w(u'')
+ w(u'%s | %s |
' % (
+ _('config type'), self._cw.vreg.config.name))
+ w(u'%s | %s |
' % (
+ _('config mode'), self._cw.vreg.config.mode))
+ w(u'%s | %s |
' % (
+ _('instance home'), self._cw.vreg.config.apphome))
+ w(u'
')
+ vcconf = req.vreg.config.vc_config()
+ w(u'%s
' % _('versions configuration'))
+ w(u'')
+ w(u'%s | %s |
' % (
+ 'CubicWeb', vcconf.get('cubicweb', _('no version information'))))
+ for cube in sorted(self._cw.vreg.config.cubes()):
+ cubeversion = vcconf.get(cube, _('no version information'))
+ w(u'%s | %s |
' % (
+ cube, cubeversion))
+ w(u'
')
+ # repository information
+ repo = req.vreg.config.repository(None)
+ w(u'%s
' % _('Repository'))
+ w(u'%s
' % _('resources usage'))
+ w(u'')
+ stats = repo.stats()
+ for element in sorted(stats):
+ w(u'%s | %s %s |
'
+ % (element, stats[element],
+ element.endswith('percent') and '%' or '' ))
+ w(u'
')
+ if req.cnx._cnxtype == 'inmemory':
+ w(u'%s
' % _('opened sessions'))
+ sessions = repo._sessions.values()
+ if sessions:
+ w(u'')
+ for session in sessions:
+ w(u'- %s (%s: %s)
' % (
+ xml_escape(unicode(session)),
+ _('last usage'),
+ strftime(dtformat, localtime(session.timestamp))))
+ dict_to_html(w, session.data)
+ w(u' ')
+ w(u'
')
+ else:
+ w(u'%s
' % _('no repository sessions found'))
+ # web server information
+ w(u'%s
' % _('Web server'))
+ w(u'')
+ w(u'%s | %s |
' % (
+ _('base url'), req.base_url()))
+ w(u'%s | %s |
' % (
+ _('data directory url'), req.datadir_url))
+ w(u'
')
+ from cubicweb.web.application import SESSION_MANAGER
+ sessions = SESSION_MANAGER.current_sessions()
+ w(u'%s
' % _('opened web sessions'))
if sessions:
w(u'')
- for sid, session in sessions:
- w(u'- %s (last usage: %s)
' % (xml_escape(str(session)),
- strftime('%Y-%m-%d %H:%M:%S',
- localtime(session.timestamp))))
+ for session in sessions:
+ w(u' - %s (%s: %s)
' % (
+ session.sessionid,
+ _('last usage'),
+ strftime(dtformat, localtime(session.last_usage_time))))
dict_to_html(w, session.data)
w(u' ')
w(u'
')
else:
- w(u'no server sessions found
')
- from cubicweb.web.application import SESSION_MANAGER
- w(u'web sessions
')
- sessions = SESSION_MANAGER.current_sessions()
- if sessions:
- w(u'')
- for session in sessions:
- w(u'- %s (last usage: %s)
' % (session.sessionid,
- strftime('%Y-%m-%d %H:%M:%S',
- localtime(session.last_usage_time))))
- dict_to_html(w, session.data)
- w(u' ')
- w(u'
')
- else:
- w(u'no web sessions found
')
+ w(u'%s
' % _('no web sessions found'))
+
class RegistryView(StartupView):