author | Alexandre Fayolle <alexandre.fayolle@logilab.fr> |
Mon, 23 Aug 2010 09:07:20 +0200 | |
branch | stable |
changeset 6134 | 272cfcc10a28 |
parent 6016 | 0eabedcfb0a9 |
child 6020 | 6f3b4f20ee9f |
permissions | -rw-r--r-- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5248
diff
changeset
|
1 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5248
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5248
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5248
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5248
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5248
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5248
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5248
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5248
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5248
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5248
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5248
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5248
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5248
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5248
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5248
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
5824 | 18 |
"""management and error screens""" |
0 | 19 |
|
20 |
__docformat__ = "restructuredtext en" |
|
21 |
||
22 |
from time import strftime, localtime |
|
23 |
||
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
24 |
from logilab.mtconverter import xml_escape |
0 | 25 |
|
635
305da8d6aa2d
require_group/match_user_group -> match_user_groups
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
26 |
from cubicweb.selectors import none_rset, match_user_groups |
981
d86d1ee3b60e
fix some imports, update treeview for 3.2
sylvain.thenault@logilab.fr
parents:
742
diff
changeset
|
27 |
from cubicweb.view import StartupView |
5963
4d75f743ed49
[actions] homogen action/view selectors. Move action together with associated view to avoid such thing in the future
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5825
diff
changeset
|
28 |
from cubicweb.web.views import actions |
0 | 29 |
|
30 |
def dict_to_html(w, dict): |
|
31 |
# XHTML doesn't allow emtpy <ul> nodes |
|
32 |
if dict: |
|
33 |
w(u'<ul>') |
|
34 |
for key in sorted(dict): |
|
35 |
w(u'<li><span class="label">%s</span>: <span>%s</span></li>' % ( |
|
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
36 |
xml_escape(str(key)), xml_escape(repr(dict[key])))) |
0 | 37 |
w(u'</ul>') |
635
305da8d6aa2d
require_group/match_user_group -> match_user_groups
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
38 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
981
diff
changeset
|
39 |
|
4714
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
40 |
|
5963
4d75f743ed49
[actions] homogen action/view selectors. Move action together with associated view to avoid such thing in the future
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5825
diff
changeset
|
41 |
class SiteInfoAction(actions.ManagersAction): |
4d75f743ed49
[actions] homogen action/view selectors. Move action together with associated view to avoid such thing in the future
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5825
diff
changeset
|
42 |
__regid__ = 'siteinfo' |
4d75f743ed49
[actions] homogen action/view selectors. Move action together with associated view to avoid such thing in the future
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5825
diff
changeset
|
43 |
__select__ = match_user_groups('users','managers') |
4d75f743ed49
[actions] homogen action/view selectors. Move action together with associated view to avoid such thing in the future
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5825
diff
changeset
|
44 |
title = _('info') |
4d75f743ed49
[actions] homogen action/view selectors. Move action together with associated view to avoid such thing in the future
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5825
diff
changeset
|
45 |
order = 30 |
4d75f743ed49
[actions] homogen action/view selectors. Move action together with associated view to avoid such thing in the future
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5825
diff
changeset
|
46 |
|
4d75f743ed49
[actions] homogen action/view selectors. Move action together with associated view to avoid such thing in the future
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5825
diff
changeset
|
47 |
|
4714
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
48 |
class ProcessInformationView(StartupView): |
4865
90ad729d3540
[debug] minor improvments to the registry view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4725
diff
changeset
|
49 |
"""display various web server /repository information""" |
4714
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
50 |
__regid__ = 'info' |
5963
4d75f743ed49
[actions] homogen action/view selectors. Move action together with associated view to avoid such thing in the future
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5825
diff
changeset
|
51 |
__select__ = none_rset() & match_user_groups('managers', 'users') |
4714
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
52 |
|
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
53 |
title = _('server information') |
5825
2daf1ac79d5c
[debug views] set http cache max age to 0 on debug views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5824
diff
changeset
|
54 |
cache_max_age = 0 |
0 | 55 |
|
56 |
def call(self, **kwargs): |
|
4714
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
57 |
req = self._cw |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
58 |
dtformat = req.property_value('ui.datetime-format') |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
59 |
_ = req._ |
0 | 60 |
w = self.w |
4714
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
61 |
# generic instance information |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
62 |
w(u'<h1>%s</h1>' % _('Instance')) |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
63 |
w(u'<table>') |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
64 |
w(u'<tr><th align="left">%s</th><td>%s</td></tr>' % ( |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
65 |
_('config type'), self._cw.vreg.config.name)) |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
66 |
w(u'<tr><th align="left">%s</th><td>%s</td></tr>' % ( |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
67 |
_('config mode'), self._cw.vreg.config.mode)) |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
68 |
w(u'<tr><th align="left">%s</th><td>%s</td></tr>' % ( |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
69 |
_('instance home'), self._cw.vreg.config.apphome)) |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
70 |
w(u'</table>') |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
71 |
vcconf = req.vreg.config.vc_config() |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
72 |
w(u'<h3>%s</h3>' % _('versions configuration')) |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
73 |
w(u'<table>') |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
74 |
w(u'<tr><th align="left">%s</th><td>%s</td></tr>' % ( |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
75 |
'CubicWeb', vcconf.get('cubicweb', _('no version information')))) |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
76 |
for cube in sorted(self._cw.vreg.config.cubes()): |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
77 |
cubeversion = vcconf.get(cube, _('no version information')) |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
78 |
w(u'<tr><th align="left">%s</th><td>%s</td></tr>' % ( |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
79 |
cube, cubeversion)) |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
80 |
w(u'</table>') |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
81 |
# repository information |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
82 |
repo = req.vreg.config.repository(None) |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
83 |
w(u'<h1>%s</h1>' % _('Repository')) |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
84 |
w(u'<h3>%s</h3>' % _('resources usage')) |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
85 |
w(u'<table>') |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
86 |
stats = repo.stats() |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
87 |
for element in sorted(stats): |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
88 |
w(u'<tr><th align="left">%s</th><td>%s %s</td></tr>' |
4725 | 89 |
% (element, xml_escape(unicode(stats[element])), |
4714
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
90 |
element.endswith('percent') and '%' or '' )) |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
91 |
w(u'</table>') |
6016
0eabedcfb0a9
[security] do not show sessions information to non managers users. Close security ticket #38246
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5963
diff
changeset
|
92 |
if req.cnx._cnxtype == 'inmemory' and req.user.is_in_group('managers'): |
4714
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
93 |
w(u'<h3>%s</h3>' % _('opened sessions')) |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
94 |
sessions = repo._sessions.values() |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
95 |
if sessions: |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
96 |
w(u'<ul>') |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
97 |
for session in sessions: |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
98 |
w(u'<li>%s (%s: %s)<br/>' % ( |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
99 |
xml_escape(unicode(session)), |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
100 |
_('last usage'), |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
101 |
strftime(dtformat, localtime(session.timestamp)))) |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
102 |
dict_to_html(w, session.data) |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
103 |
w(u'</li>') |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
104 |
w(u'</ul>') |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
105 |
else: |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
106 |
w(u'<p>%s</p>' % _('no repository sessions found')) |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
107 |
# web server information |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
108 |
w(u'<h1>%s</h1>' % _('Web server')) |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
109 |
w(u'<table>') |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
110 |
w(u'<tr><th align="left">%s</th><td>%s</td></tr>' % ( |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
111 |
_('base url'), req.base_url())) |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
112 |
w(u'<tr><th align="left">%s</th><td>%s</td></tr>' % ( |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
113 |
_('data directory url'), req.datadir_url)) |
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
114 |
w(u'</table>') |
6016
0eabedcfb0a9
[security] do not show sessions information to non managers users. Close security ticket #38246
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5963
diff
changeset
|
115 |
if req.user.is_in_group('managers'): |
0eabedcfb0a9
[security] do not show sessions information to non managers users. Close security ticket #38246
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5963
diff
changeset
|
116 |
from cubicweb.web.application import SESSION_MANAGER |
0eabedcfb0a9
[security] do not show sessions information to non managers users. Close security ticket #38246
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5963
diff
changeset
|
117 |
sessions = SESSION_MANAGER.current_sessions() |
0eabedcfb0a9
[security] do not show sessions information to non managers users. Close security ticket #38246
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5963
diff
changeset
|
118 |
w(u'<h3>%s</h3>' % _('opened web sessions')) |
0eabedcfb0a9
[security] do not show sessions information to non managers users. Close security ticket #38246
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5963
diff
changeset
|
119 |
if sessions: |
0eabedcfb0a9
[security] do not show sessions information to non managers users. Close security ticket #38246
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5963
diff
changeset
|
120 |
w(u'<ul>') |
0eabedcfb0a9
[security] do not show sessions information to non managers users. Close security ticket #38246
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5963
diff
changeset
|
121 |
for session in sessions: |
0eabedcfb0a9
[security] do not show sessions information to non managers users. Close security ticket #38246
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5963
diff
changeset
|
122 |
w(u'<li>%s (%s: %s)<br/>' % ( |
0eabedcfb0a9
[security] do not show sessions information to non managers users. Close security ticket #38246
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5963
diff
changeset
|
123 |
session.sessionid, |
0eabedcfb0a9
[security] do not show sessions information to non managers users. Close security ticket #38246
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5963
diff
changeset
|
124 |
_('last usage'), |
0eabedcfb0a9
[security] do not show sessions information to non managers users. Close security ticket #38246
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5963
diff
changeset
|
125 |
strftime(dtformat, localtime(session.last_usage_time)))) |
0eabedcfb0a9
[security] do not show sessions information to non managers users. Close security ticket #38246
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5963
diff
changeset
|
126 |
dict_to_html(w, session.data) |
0eabedcfb0a9
[security] do not show sessions information to non managers users. Close security ticket #38246
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5963
diff
changeset
|
127 |
w(u'</li>') |
0eabedcfb0a9
[security] do not show sessions information to non managers users. Close security ticket #38246
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5963
diff
changeset
|
128 |
w(u'</ul>') |
0eabedcfb0a9
[security] do not show sessions information to non managers users. Close security ticket #38246
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5963
diff
changeset
|
129 |
else: |
0eabedcfb0a9
[security] do not show sessions information to non managers users. Close security ticket #38246
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5963
diff
changeset
|
130 |
w(u'<p>%s</p>' % _('no web sessions found')) |
4714
fccda6dd91bf
merge debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
131 |
|
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
132 |
|
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
133 |
|
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
134 |
class RegistryView(StartupView): |
4865
90ad729d3540
[debug] minor improvments to the registry view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4725
diff
changeset
|
135 |
"""display vregistry content""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
136 |
__regid__ = 'registry' |
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
137 |
__select__ = StartupView.__select__ & match_user_groups('managers') |
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
138 |
title = _('registry') |
5825
2daf1ac79d5c
[debug views] set http cache max age to 0 on debug views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5824
diff
changeset
|
139 |
cache_max_age = 0 |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
140 |
|
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
141 |
def call(self, **kwargs): |
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
142 |
self.w(u'<h1>%s</h1>' % _("Registry's content")) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
143 |
keys = sorted(self._cw.vreg) |
4916 | 144 |
url = xml_escape(self._cw.url()) |
4865
90ad729d3540
[debug] minor improvments to the registry view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4725
diff
changeset
|
145 |
self.w(u'<p>%s</p>\n' % ' - '.join('<a href="%s#%s">%s</a>' |
90ad729d3540
[debug] minor improvments to the registry view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4725
diff
changeset
|
146 |
% (url, key, key) for key in keys)) |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
147 |
for key in keys: |
4865
90ad729d3540
[debug] minor improvments to the registry view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4725
diff
changeset
|
148 |
self.w(u'<h2 id="%s">%s</h2>' % (key, key)) |
90ad729d3540
[debug] minor improvments to the registry view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4725
diff
changeset
|
149 |
if self._cw.vreg[key]: |
90ad729d3540
[debug] minor improvments to the registry view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4725
diff
changeset
|
150 |
values = sorted(self._cw.vreg[key].iteritems()) |
90ad729d3540
[debug] minor improvments to the registry view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4725
diff
changeset
|
151 |
self.wview('pyvaltable', pyvalue=[(key, xml_escape(repr(val))) |
90ad729d3540
[debug] minor improvments to the registry view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4725
diff
changeset
|
152 |
for key, val in values]) |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
153 |
else: |
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
154 |
self.w(u'<p>Empty</p>\n') |
4866
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
155 |
|
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
156 |
|
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
157 |
class GCView(StartupView): |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
158 |
"""display garbage collector information""" |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
159 |
__regid__ = 'gc' |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
160 |
__select__ = StartupView.__select__ & match_user_groups('managers') |
4873 | 161 |
title = _('memory leak debugging') |
5825
2daf1ac79d5c
[debug views] set http cache max age to 0 on debug views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5824
diff
changeset
|
162 |
cache_max_age = 0 |
4866
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
163 |
|
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
164 |
def call(self, **kwargs): |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
165 |
from cubicweb._gcdebug import gc_info |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
166 |
from rql.stmts import Union |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
167 |
from cubicweb.appobject import AppObject |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
168 |
from cubicweb.rset import ResultSet |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
169 |
from cubicweb.dbapi import Connection, Cursor |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
170 |
from cubicweb.web.request import CubicWebRequestBase |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
171 |
lookupclasses = (AppObject, |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
172 |
Union, ResultSet, |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
173 |
Connection, Cursor, |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
174 |
CubicWebRequestBase) |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
175 |
try: |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
176 |
from cubicweb.server.session import Session, ChildSession, InternalSession |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
177 |
lookupclasses += (InternalSession, ChildSession, Session) |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
178 |
except ImportError: |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
179 |
pass # no server part installed |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
180 |
self.w(u'<h1>%s</h1>' % _('Garbage collection information')) |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
181 |
counters, ocounters, garbage = gc_info(lookupclasses, |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
182 |
viewreferrersclasses=()) |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
183 |
self.w(u'<h3>%s</h3>' % _('Looked up classes')) |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
184 |
values = sorted(counters.iteritems(), key=lambda x: x[1], reverse=True) |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
185 |
self.wview('pyvaltable', pyvalue=values) |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
186 |
self.w(u'<h3>%s</h3>' % _('Most referenced classes')) |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
187 |
values = sorted(ocounters.iteritems(), key=lambda x: x[1], reverse=True) |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
188 |
self.wview('pyvaltable', pyvalue=values[:self._cw.form.get('nb', 20)]) |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
189 |
if garbage: |
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
190 |
self.w(u'<h3>%s</h3>' % _('Unreachable objects')) |
5248
8f7843afb014
[views] fix bug on gc debugging view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4916
diff
changeset
|
191 |
values = sorted(xml_escape(repr(o)) for o in garbage) |
4866
550e35a69b75
[debug] a new view to help debugging memory leaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4865
diff
changeset
|
192 |
self.wview('pyvallist', pyvalue=values) |