# HG changeset patch # User RĂ©mi Cardona # Date 1448469092 -3600 # Node ID 2125def9498b968fdce0ff033e7722e3d0dbcdbe # Parent 846e5676ca39f68c23d7c0b73b44134a6772c3f3 [views] Use 'pyvaltable' instead of hand-crafted tags diff -r 846e5676ca39 -r 2125def9498b web/views/debug.py --- a/web/views/debug.py Tue Nov 24 17:31:09 2015 +0100 +++ b/web/views/debug.py Wed Nov 25 17:31:32 2015 +0100 @@ -35,7 +35,7 @@ if dict: w(u'') @@ -76,28 +76,20 @@ repo = req.cnx.repo # generic instance information w(u'

%s

' % _('Instance')) - w(u'
') - w(u'' % ( - _('config type'), self._cw.vreg.config.name)) - w(u'' % ( - _('config mode'), self._cw.vreg.config.mode)) - w(u'' % ( - _('instance home'), self._cw.vreg.config.apphome)) - w(u'
%s%s
%s%s
%s%s
') + pyvalue = ((_('config type'), self._cw.vreg.config.name), + (_('config mode'), self._cw.vreg.config.mode), + (_('instance home'), self._cw.vreg.config.apphome)) + self.wview('pyvaltable', pyvalue=pyvalue, header_column_idx=0) vcconf = repo.get_versions() w(u'

%s

' % _('versions configuration')) - w(u'') - w(u'' % ( - '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'' % ( - cube, cubeversion)) - w(u'
%s%s
%s%s
') + missing = _('no version information') + pyvalue = [('CubicWeb', vcconf.get('cubicweb', missing))] + pyvalue += [(cube, vcconf.get(cube, missing)) + for cube in sorted(self._cw.vreg.config.cubes())] + self.wview('pyvaltable', pyvalue=pyvalue, header_column_idx=0) # repository information w(u'

%s

' % _('Repository')) w(u'

%s

' % _('resources usage')) - w(u'') stats = self._cw.call_service('repo_stats') stats['looping_tasks'] = ', '.join('%s (%s seconds)' % (n, i) for n, i in stats['looping_tasks']) stats['threads'] = ', '.join(sorted(stats['threads'])) @@ -106,11 +98,13 @@ continue if k.endswith('_cache_size'): stats[k] = '%s / %s' % (stats[k]['size'], stats[k]['maxsize']) - for element in sorted(stats): - w(u'' - % (element, xml_escape(text_type(stats[element])), - element.endswith('percent') and '%' or '' )) - w(u'
%s%s %s
') + def format_stat(sname, sval): + return '%s %s' % (xml_escape(text_type(sval)), + sname.endswith('percent') and '%' or '') + pyvalue = [(sname, format_stat(sname, sval)) + for sname, sval in sorted(stats.items())] + self.wview('pyvaltable', pyvalue=pyvalue, header_column_idx=0) + # open repo sessions if req.cnx.is_repo_in_memory and req.user.is_in_group('managers'): w(u'

%s

' % _('opened sessions')) sessions = repo._sessions.values() @@ -128,12 +122,9 @@ w(u'

%s

' % _('no repository sessions found')) # web server information w(u'

%s

' % _('Web server')) - w(u'') - w(u'' % ( - _('base url'), req.base_url())) - w(u'' % ( - _('data directory url'), req.datadir_url)) - w(u'
%s%s
%s%s
') + pyvalue = ((_('base url'), req.base_url()), + (_('data directory url'), req.datadir_url)) + self.wview('pyvaltable', pyvalue=pyvalue, header_column_idx=0) from cubicweb.web.application import SESSION_MANAGER if SESSION_MANAGER is not None and req.user.is_in_group('managers'): sessions = SESSION_MANAGER.current_sessions()