[views] fix ProcessInformationView: SESSION_MANAGER can be None (closes #5753280)

eg. with pyramid.

authorDavid Douard <david.douard@logilab.fr>
changesetb0fde3192814
branchdefault
phasedraft
hiddenyes
parent revision#2b398e58ea73 [hook] remove assumption about entity cache vs cw_edited
child revision<not specified>
files modified by this revision
web/views/debug.py
# HG changeset patch
# User David Douard <david.douard@logilab.fr>
# Date 1437984032 -7200
# Mon Jul 27 10:00:32 2015 +0200
# Node ID b0fde319281488d8601a13f5124e0aec0b43cc0a
# Parent 2b398e58ea7351ceb94389ceacb7a0d091f2da6d
[views] fix ProcessInformationView: SESSION_MANAGER can be None (closes #5753280)

eg. with pyramid.

diff --git a/web/views/debug.py b/web/views/debug.py
@@ -126,25 +126,26 @@
1          w(u'<tr><th align="left">%s</th><td>%s</td></tr>' % (
2              _('data directory url'), req.datadir_url))
3          w(u'</table>')
4          if req.user.is_in_group('managers'):
5              from cubicweb.web.application import SESSION_MANAGER
6 -            sessions = SESSION_MANAGER.current_sessions()
7 -            w(u'<h3>%s</h3>' % _('opened web sessions'))
8 -            if sessions:
9 -                w(u'<ul>')
10 -                for session in sessions:
11 -                    last_usage_time = session.mtime
12 -                    w(u'<li>%s (%s: %s)<br/>' % (
13 -                        session.sessionid,
14 -                        _('last usage'),
15 -                        strftime(dtformat, localtime(last_usage_time))))
16 -                    dict_to_html(w, session.data)
17 -                    w(u'</li>')
18 -                w(u'</ul>')
19 -            else:
20 -                w(u'<p>%s</p>' % _('no web sessions found'))
21 +            if SESSION_MANAGER:
22 +                sessions = SESSION_MANAGER.current_sessions()
23 +                w(u'<h3>%s</h3>' % _('opened web sessions'))
24 +                if sessions:
25 +                    w(u'<ul>')
26 +                    for session in sessions:
27 +                        last_usage_time = session.mtime
28 +                        w(u'<li>%s (%s: %s)<br/>' % (
29 +                            session.sessionid,
30 +                            _('last usage'),
31 +                            strftime(dtformat, localtime(last_usage_time))))
32 +                        dict_to_html(w, session.data)
33 +                        w(u'</li>')
34 +                    w(u'</ul>')
35 +                else:
36 +                    w(u'<p>%s</p>' % _('no web sessions found'))
37 
38 
39 
40  class RegistryView(StartupView):
41      """display vregistry content"""