web/views/debug.py
changeset 8718 9e7847dcbd94
parent 8696 0bb18407c053
parent 8714 b70295aaed9d
child 9034 cc3442054e48
equal deleted inserted replaced
8713:4b34dc3046e6 8718:9e7847dcbd94
   129         if req.user.is_in_group('managers'):
   129         if req.user.is_in_group('managers'):
   130             from cubicweb.web.application import SESSION_MANAGER
   130             from cubicweb.web.application import SESSION_MANAGER
   131             sessions = SESSION_MANAGER.current_sessions()
   131             sessions = SESSION_MANAGER.current_sessions()
   132             w(u'<h3>%s</h3>' % _('opened web sessions'))
   132             w(u'<h3>%s</h3>' % _('opened web sessions'))
   133             if sessions:
   133             if sessions:
       
   134                 n_no_cnx_sessions = 0
   134                 w(u'<ul>')
   135                 w(u'<ul>')
   135                 for session in sessions:
   136                 for session in sessions:
   136                     if not session.cnx:
   137                     if not session.cnx:
   137                         w(u'<li>%s (NO CNX)</li>' % session.sessionid)
   138                         # We do not want to list all sessions without cnx
       
   139                         # Their session ID are useless, hence we just count them
       
   140                         n_no_cnx_sessions += 1
   138                         continue
   141                         continue
   139                     try:
   142                     try:
   140                         last_usage_time = session.cnx.check()
   143                         last_usage_time = session.cnx.check()
   141                     except BadConnectionId:
   144                     except BadConnectionId:
   142                         w(u'<li>%s (INVALID)</li>' % session.sessionid)
   145                         w(u'<li>%s (INVALID)</li>' % session.sessionid)
   146                         _('last usage'),
   149                         _('last usage'),
   147                         strftime(dtformat, localtime(last_usage_time))))
   150                         strftime(dtformat, localtime(last_usage_time))))
   148                     dict_to_html(w, session.data)
   151                     dict_to_html(w, session.data)
   149                     w(u'</li>')
   152                     w(u'</li>')
   150                 w(u'</ul>')
   153                 w(u'</ul>')
       
   154                 if n_no_cnx_sessions > 0:
       
   155                     w(u'<h3>%s %s</h3>' % (n_no_cnx_sessions,
       
   156                                            _('web sessions without CNX')))
   151             else:
   157             else:
   152                 w(u'<p>%s</p>' % _('no web sessions found'))
   158                 w(u'<p>%s</p>' % _('no web sessions found'))
   153 
   159 
   154 
   160 
   155 
   161