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