author | sylvain.thenault@logilab.fr |
Fri, 17 Apr 2009 16:55:37 +0200 | |
branch | tls-sprint |
changeset 1398 | 5fe84a5f7035 |
parent 1388 | 6d5f0ccf31b8 |
child 1402 | 04b7afb14b50 |
permissions | -rw-r--r-- |
0 | 1 |
"""management and error screens |
2 |
||
3 |
||
4 |
:organization: Logilab |
|
635
305da8d6aa2d
require_group/match_user_group -> match_user_groups
sylvain.thenault@logilab.fr
parents:
631
diff
changeset
|
5 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
0 | 6 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
7 |
""" |
|
8 |
__docformat__ = "restructuredtext en" |
|
9 |
||
10 |
from logilab.mtconverter import html_escape |
|
11 |
||
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
12 |
from cubicweb.selectors import yes, none_rset, match_user_groups |
836 | 13 |
from cubicweb.view import AnyRsetView, StartupView, EntityView |
604
e85042d18b48
[preferences] preferences sections will now remember their collapsed/open status
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
602
diff
changeset
|
14 |
from cubicweb.common.uilib import html_traceback, rest_traceback |
0 | 15 |
from cubicweb.web import INTERNAL_FIELD_VALUE, eid_param, stdmsgs |
16 |
from cubicweb.web.widgets import StaticComboBoxWidget |
|
17 |
||
18 |
_ = unicode |
|
602
1454282a8b45
[views] cleanup, be less heavy with self.w ...
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
19 |
|
1388
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
20 |
SUBMIT_MSGID = _('Submit bug report') |
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
21 |
MAIL_SUBMIT_MSGID = _('Submit bug report by mail') |
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
22 |
|
0 | 23 |
def begin_form(w, entity, redirectvid, redirectpath=None, msg=None): |
24 |
w(u'<form method="post" action="%s">\n' % entity.req.build_url('edit')) |
|
25 |
w(u'<fieldset>\n') |
|
26 |
w(u'<input type="hidden" name="__redirectvid" value="%s"/>\n' % redirectvid) |
|
27 |
w(u'<input type="hidden" name="__redirectpath" value="%s"/>\n' % ( |
|
28 |
html_escape(redirectpath or entity.rest_path()))) |
|
29 |
w(u'<input type="hidden" name="eid" value="%s"/>\n' % entity.eid) |
|
30 |
w(u'<input type="hidden" name="%s" value="%s"/>\n' % ( |
|
31 |
eid_param('__type', entity.eid), entity.e_schema)) |
|
32 |
if msg: |
|
33 |
w(u'<input type="hidden" name="__message" value="%s"/>\n' |
|
34 |
% html_escape(msg)) |
|
35 |
||
36 |
||
37 |
class SecurityManagementView(EntityView): |
|
38 |
"""display security information for a given entity""" |
|
39 |
id = 'security' |
|
40 |
title = _('security') |
|
602
1454282a8b45
[views] cleanup, be less heavy with self.w ...
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
41 |
|
0 | 42 |
def cell_call(self, row, col): |
602
1454282a8b45
[views] cleanup, be less heavy with self.w ...
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
43 |
self.req.add_js('cubicweb.edition.js') |
1454282a8b45
[views] cleanup, be less heavy with self.w ...
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
44 |
self.req.add_css('cubicweb.acl.css') |
0 | 45 |
entity = self.entity(row, col) |
46 |
w = self.w |
|
47 |
_ = self.req._ |
|
48 |
w(u'<h1><span class="etype">%s</span> <a href="%s">%s</a></h1>' |
|
49 |
% (entity.dc_type().capitalize(), |
|
50 |
html_escape(entity.absolute_url()), |
|
51 |
html_escape(entity.dc_title()))) |
|
52 |
# first show permissions defined by the schema |
|
53 |
self.w('<h2>%s</h2>' % _('schema\'s permissions definitions')) |
|
54 |
self.schema_definition(entity) |
|
55 |
self.w('<h2>%s</h2>' % _('manage security')) |
|
56 |
# ownership information |
|
57 |
if self.schema.rschema('owned_by').has_perm(self.req, 'add', |
|
58 |
fromeid=entity.eid): |
|
59 |
self.owned_by_edit_form(entity) |
|
60 |
else: |
|
61 |
self.owned_by_information(entity) |
|
62 |
# epermissions |
|
63 |
if 'require_permission' in entity.e_schema.subject_relations(): |
|
64 |
w('<h3>%s</h3>' % _('permissions for this entity')) |
|
65 |
reqpermschema = self.schema.rschema('require_permission') |
|
66 |
self.require_permission_information(entity, reqpermschema) |
|
67 |
if reqpermschema.has_perm(self.req, 'add', fromeid=entity.eid): |
|
68 |
self.require_permission_edit_form(entity) |
|
69 |
||
70 |
def schema_definition(self, entity): |
|
71 |
w = self.w |
|
72 |
_ = self.req._ |
|
73 |
w(u'<table class="schemaInfo">') |
|
74 |
w(u'<tr><th>%s</th><th>%s</th><th>%s</th></tr>' % ( |
|
75 |
_("access type"), _('granted to groups'), _('rql expressions'))) |
|
76 |
for access_type in ('read', 'add', 'update', 'delete'): |
|
77 |
w(u'<tr>') |
|
78 |
w(u'<th>%s</th>' % self.req.__('%s_permission' % access_type)) |
|
79 |
groups = entity.e_schema.get_groups(access_type) |
|
80 |
l = [] |
|
81 |
for group in groups: |
|
82 |
l.append(u'<a href="%s">%s</a>' % ( |
|
83 |
self.build_url('egroup/%s' % group), _(group))) |
|
84 |
w(u'<td>%s</td>' % u', '.join(l)) |
|
85 |
rqlexprs = entity.e_schema.get_rqlexprs(access_type) |
|
86 |
w(u'<td>%s</td>' % u'<br/>'.join(expr.expression for expr in rqlexprs)) |
|
87 |
w(u'</tr>\n') |
|
88 |
w(u'</table>') |
|
602
1454282a8b45
[views] cleanup, be less heavy with self.w ...
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
89 |
|
0 | 90 |
def owned_by_edit_form(self, entity): |
91 |
self.w('<h3>%s</h3>' % self.req._('ownership')) |
|
92 |
begin_form(self.w, entity, 'security', msg= _('ownerships have been changed')) |
|
93 |
self.w(u'<table border="0">\n') |
|
94 |
self.w(u'<tr><td>\n') |
|
95 |
wdg = entity.get_widget('owned_by') |
|
96 |
self.w(wdg.edit_render(entity)) |
|
97 |
self.w(u'</td><td>\n') |
|
98 |
self.w(self.button_ok()) |
|
99 |
self.w(u'</td></tr>\n</table>\n') |
|
100 |
self.w(u'</fieldset></form>\n') |
|
101 |
||
102 |
def owned_by_information(self, entity): |
|
103 |
ownersrset = entity.related('owned_by') |
|
104 |
if ownersrset: |
|
105 |
self.w('<h3>%s</h3>' % self.req._('ownership')) |
|
106 |
self.w(u'<div class="ownerInfo">') |
|
107 |
self.w(self.req._('this entity is currently owned by') + ' ') |
|
108 |
self.wview('csv', entity.related('owned_by'), 'null') |
|
109 |
self.w(u'</div>') |
|
110 |
# else we don't know if this is because entity has no owner or becayse |
|
111 |
# user as no access to owner users entities |
|
112 |
||
113 |
def require_permission_information(self, entity, reqpermschema): |
|
114 |
if entity.require_permission: |
|
115 |
w = self.w |
|
116 |
_ = self.req._ |
|
117 |
if reqpermschema.has_perm(self.req, 'delete', fromeid=entity.eid): |
|
118 |
delurl = self.build_url('edit', __redirectvid='security', |
|
119 |
__redirectpath=entity.rest_path()) |
|
120 |
delurl = delurl.replace('%', '%%') |
|
121 |
# don't give __delete value to build_url else it will be urlquoted |
|
122 |
# and this will replace %s by %25s |
|
123 |
delurl += '&__delete=%s:require_permission:%%s' % entity.eid |
|
124 |
dellinktempl = u'[<a href="%s" title="%s">-</a>] ' % ( |
|
125 |
html_escape(delurl), _('delete this permission')) |
|
126 |
else: |
|
127 |
dellinktempl = None |
|
128 |
w(u'<table class="schemaInfo">') |
|
129 |
w(u'<tr><th>%s</th><th>%s</th></tr>' % (_("permission"), |
|
130 |
_('granted to groups'))) |
|
131 |
for eperm in entity.require_permission: |
|
132 |
w(u'<tr>') |
|
133 |
if dellinktempl: |
|
134 |
w(u'<td>%s%s</td>' % (dellinktempl % eperm.eid, |
|
135 |
eperm.view('oneline'))) |
|
136 |
else: |
|
137 |
w(u'<td>%s</td>' % eperm.view('oneline')) |
|
138 |
w(u'<td>%s</td>' % self.view('csv', eperm.related('require_group'), 'null')) |
|
139 |
w(u'</tr>\n') |
|
140 |
w(u'</table>') |
|
141 |
else: |
|
142 |
self.w(self.req._('no associated epermissions')) |
|
143 |
||
144 |
def require_permission_edit_form(self, entity): |
|
145 |
w = self.w |
|
146 |
_ = self.req._ |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1388
diff
changeset
|
147 |
newperm = self.vreg.etype_class('CWPermission')(self.req, None) |
0 | 148 |
newperm.eid = self.req.varmaker.next() |
149 |
w(u'<p>%s</p>' % _('add a new permission')) |
|
150 |
begin_form(w, newperm, 'security', entity.rest_path()) |
|
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
151 |
w(u'<input type="hidden" name="%s" value="%s"/>' |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
152 |
% (eid_param('edito-require_permission', newperm.eid), INTERNAL_FIELD_VALUE)) |
0 | 153 |
w(u'<input type="hidden" name="%s" value="%s"/>' |
154 |
% (eid_param('require_permission', newperm.eid), entity.eid)) |
|
155 |
w(u'<table border="0">\n') |
|
156 |
w(u'<tr><th>%s</th><th>%s</th><th>%s</th><th> </th></tr>\n' |
|
157 |
% (_("name"), _("label"), _('granted to groups'))) |
|
158 |
if getattr(entity, '__permissions__', None): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1388
diff
changeset
|
159 |
wdg = StaticComboBoxWidget(self.vreg, self.schema['CWPermission'], |
0 | 160 |
self.schema['name'], self.schema['String'], |
161 |
vocabfunc=lambda x: entity.__permissions__) |
|
162 |
else: |
|
163 |
wdg = newperm.get_widget('name') |
|
164 |
w(u'<tr><td>%s</td>\n' % wdg.edit_render(newperm)) |
|
165 |
wdg = newperm.get_widget('label') |
|
166 |
w(u'<td>%s</td>\n' % wdg.edit_render(newperm)) |
|
167 |
wdg = newperm.get_widget('require_group') |
|
602
1454282a8b45
[views] cleanup, be less heavy with self.w ...
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
168 |
w(u'<td>%s</td>\n' % wdg.edit_render(newperm)) |
0 | 169 |
w(u'<td>%s</td></tr>\n' % self.button_ok()) |
170 |
w(u'</table>') |
|
171 |
w(u'</fieldset></form>\n') |
|
172 |
||
173 |
def button_ok(self): |
|
174 |
return (u'<input class="validateButton" type="submit" name="submit" value="%s"/>' |
|
175 |
% self.req._(stdmsgs.BUTTON_OK)) |
|
176 |
||
602
1454282a8b45
[views] cleanup, be less heavy with self.w ...
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
177 |
|
0 | 178 |
class ErrorView(AnyRsetView): |
179 |
"""default view when no result has been found""" |
|
731
ac4a94e50b60
some more s/__selectors__/__select__ but still more to come
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
691
diff
changeset
|
180 |
__select__ = yes() |
0 | 181 |
id = 'error' |
602
1454282a8b45
[views] cleanup, be less heavy with self.w ...
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
182 |
|
0 | 183 |
def page_title(self): |
184 |
"""returns a title according to the result set - used for the |
|
185 |
title in the HTML header |
|
186 |
""" |
|
187 |
return self.req._('an error occured') |
|
188 |
||
189 |
def call(self): |
|
190 |
req = self.req.reset_headers() |
|
1388
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
191 |
w = self.w |
0 | 192 |
ex = req.data.get('ex')#_("unable to find exception information")) |
193 |
excinfo = req.data.get('excinfo') |
|
1388
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
194 |
title = self.req._('an error occured') |
602
1454282a8b45
[views] cleanup, be less heavy with self.w ...
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
195 |
w(u'<h2>%s</h2>' % title) |
0 | 196 |
if 'errmsg' in req.data: |
197 |
ex = req.data['errmsg'] |
|
174
a2966960d550
get actual exception class instead of 'unicode' in the error view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
198 |
exclass = None |
0 | 199 |
else: |
174
a2966960d550
get actual exception class instead of 'unicode' in the error view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
200 |
exclass = ex.__class__.__name__ |
0 | 201 |
ex = exc_message(ex, req.encoding) |
202 |
if excinfo is not None and self.config['print-traceback']: |
|
174
a2966960d550
get actual exception class instead of 'unicode' in the error view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
203 |
if exclass is None: |
602
1454282a8b45
[views] cleanup, be less heavy with self.w ...
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
204 |
w(u'<div class="tb">%s</div>' |
174
a2966960d550
get actual exception class instead of 'unicode' in the error view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
205 |
% html_escape(ex).replace("\n","<br />")) |
a2966960d550
get actual exception class instead of 'unicode' in the error view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
206 |
else: |
602
1454282a8b45
[views] cleanup, be less heavy with self.w ...
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
207 |
w(u'<div class="tb">%s: %s</div>' |
174
a2966960d550
get actual exception class instead of 'unicode' in the error view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
208 |
% (exclass, html_escape(ex).replace("\n","<br />"))) |
602
1454282a8b45
[views] cleanup, be less heavy with self.w ...
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
209 |
w(u'<hr />') |
1454282a8b45
[views] cleanup, be less heavy with self.w ...
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
210 |
w(u'<div class="tb">%s</div>' % html_traceback(excinfo, ex, '')) |
0 | 211 |
else: |
602
1454282a8b45
[views] cleanup, be less heavy with self.w ...
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
212 |
w(u'<div class="tb">%s</div>' % (html_escape(ex).replace("\n","<br />"))) |
0 | 213 |
# if excinfo is not None, it's probably not a bug |
214 |
if excinfo is None: |
|
215 |
return |
|
216 |
vcconf = self.config.vc_config() |
|
602
1454282a8b45
[views] cleanup, be less heavy with self.w ...
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
217 |
w(u"<div>") |
1388
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
218 |
eversion = vcconf.get('cubicweb', self.req._('no version information')) |
0 | 219 |
# NOTE: tuple wrapping needed since eversion is itself a tuple |
602
1454282a8b45
[views] cleanup, be less heavy with self.w ...
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
220 |
w(u"<b>CubicWeb version:</b> %s<br/>\n" % (eversion,)) |
1388
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
221 |
cversions = [] |
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
222 |
for cube in self.config.cubes(): |
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
223 |
cubeversion = vcconf.get(cube, self.req._('no version information')) |
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
224 |
w(u"<b>Package %s version:</b> %s<br/>\n" % (cube, cubeversion)) |
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
225 |
cversions.append((cube, cubeversion)) |
602
1454282a8b45
[views] cleanup, be less heavy with self.w ...
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
226 |
w(u"</div>") |
0 | 227 |
# creates a bug submission link if SUBMIT_URL is set |
228 |
submiturl = self.config['submit-url'] |
|
229 |
submitmail = self.config['submit-mail'] |
|
1388
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
230 |
if submiturl or submitmail: |
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
231 |
form = FieldsForm(self.req, set_error_url=False) |
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
232 |
binfo = text_error_description(ex, excinfo, req, eversion, cversions) |
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
233 |
form.form_add_hidden('description', binfo) |
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
234 |
form.form_add_hidden('__bugreporting', '1') |
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
235 |
if submitmail: |
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
236 |
form.form_buttons = [SubmitButton(MAIL_SUBMIT_MSGID)] |
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
237 |
form.action = req.build_url('reportbug') |
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
238 |
w(form.form_render()) |
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
239 |
if submiturl: |
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
240 |
form.form_add_hidden('description_format', 'text/rest') |
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
241 |
form.form_buttons = [SubmitButton(SUBMIT_MSGID)] |
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
242 |
form.action = submiturl |
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
243 |
w(form.form_render()) |
0 | 244 |
|
245 |
||
246 |
def exc_message(ex, encoding): |
|
247 |
try: |
|
248 |
return unicode(ex) |
|
249 |
except: |
|
250 |
try: |
|
251 |
return unicode(str(ex), encoding, 'replace') |
|
252 |
except: |
|
253 |
return unicode(repr(ex), encoding, 'replace') |
|
602
1454282a8b45
[views] cleanup, be less heavy with self.w ...
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
254 |
|
0 | 255 |
def text_error_description(ex, excinfo, req, eversion, cubes): |
256 |
binfo = rest_traceback(excinfo, html_escape(ex)) |
|
257 |
binfo += u'\n\n:URL: %s\n' % req.url() |
|
258 |
if not '__bugreporting' in req.form: |
|
259 |
binfo += u'\n:form params:\n' |
|
260 |
binfo += u'\n'.join(u' * %s = %s' % (k, v) for k, v in req.form.iteritems()) |
|
261 |
binfo += u'\n\n:CubicWeb version: %s\n' % (eversion,) |
|
262 |
for pkg, pkgversion in cubes: |
|
263 |
binfo += u":Package %s version: %s\n" % (pkg, pkgversion) |
|
264 |
binfo += '\n' |
|
265 |
return binfo |
|
266 |
||
1388
6d5f0ccf31b8
new style form for submitting bug reports
sylvain.thenault@logilab.fr
parents:
836
diff
changeset
|
267 |
|
0 | 268 |
class ProcessInformationView(StartupView): |
269 |
id = 'info' |
|
742
99115e029dca
replaced most of __selectors__ assignments with __select__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
731
diff
changeset
|
270 |
__select__ = none_rset() & match_user_groups('managers') |
635
305da8d6aa2d
require_group/match_user_group -> match_user_groups
sylvain.thenault@logilab.fr
parents:
631
diff
changeset
|
271 |
|
0 | 272 |
title = _('server information') |
273 |
||
274 |
def call(self, **kwargs): |
|
275 |
"""display server information""" |
|
276 |
vcconf = self.config.vc_config() |
|
277 |
req = self.req |
|
278 |
_ = req._ |
|
279 |
# display main information |
|
280 |
self.w(u'<h3>%s</h3>' % _('Application')) |
|
281 |
self.w(u'<table border="1">') |
|
282 |
self.w(u'<tr><th align="left">%s</th><td>%s</td></tr>' % ( |
|
283 |
'CubicWeb', vcconf.get('cubicweb', _('no version information')))) |
|
284 |
for pkg in self.config.cubes(): |
|
285 |
pkgversion = vcconf.get(pkg, _('no version information')) |
|
286 |
self.w(u'<tr><th align="left">%s</th><td>%s</td></tr>' % ( |
|
287 |
pkg, pkgversion)) |
|
288 |
self.w(u'<tr><th align="left">%s</th><td>%s</td></tr>' % ( |
|
289 |
_('home'), self.config.apphome)) |
|
290 |
self.w(u'<tr><th align="left">%s</th><td>%s</td></tr>' % ( |
|
291 |
_('base url'), req.base_url())) |
|
292 |
self.w(u'<tr><th align="left">%s</th><td>%s</td></tr>' % ( |
|
293 |
_('data directory url'), req.datadir_url)) |
|
294 |
self.w(u'</table>') |
|
295 |
self.w(u'<br/>') |
|
296 |
# environment and request and server information |
|
297 |
try: |
|
298 |
# need to remove our adapter and then modpython-apache wrapper... |
|
299 |
env = req._areq._req.subprocess_env |
|
300 |
except AttributeError: |
|
301 |
return |
|
302 |
self.w(u'<h3>%s</h3>' % _('Environment')) |
|
303 |
self.w(u'<table border="1">') |
|
304 |
for attr in env.keys(): |
|
305 |
self.w(u'<tr><th align="left">%s</th><td>%s</td></tr>' |
|
306 |
% (attr, html_escape(env[attr]))) |
|
307 |
self.w(u'</table>') |
|
308 |
self.w(u'<h3>%s</h3>' % _('Request')) |
|
309 |
self.w(u'<table border="1">') |
|
310 |
for attr in ('filename', 'form', 'hostname', 'main', 'method', |
|
311 |
'path_info', 'protocol', |
|
312 |
'search_state', 'the_request', 'unparsed_uri', 'uri'): |
|
313 |
val = getattr(req, attr) |
|
314 |
self.w(u'<tr><th align="left">%s</th><td>%s</td></tr>' |
|
315 |
% (attr, html_escape(val))) |
|
316 |
self.w(u'</table>') |
|
317 |
server = req.server |
|
318 |
self.w(u'<h3>%s</h3>' % _('Server')) |
|
319 |
self.w(u'<table border="1">') |
|
320 |
for attr in dir(server): |
|
321 |
val = getattr(server, attr) |
|
322 |
if attr.startswith('_') or callable(val): |
|
323 |
continue |
|
324 |
self.w(u'<tr><th align="left">%s</th><td>%s</td></tr>' |
|
325 |
% (attr, html_escape(val))) |
|
326 |
self.w(u'</table>') |
|
327 |