author | Katia Saurfelt <katia.saurfelt@logilab.fr> |
Fri, 10 Apr 2009 11:32:32 +0200 | |
changeset 1333 | 85d1bc9da0ad |
parent 1194 | e224f064a268 |
child 1263 | 01152fffd593 |
child 1413 | ad19d7e6a291 |
child 1589 | 496fdc081e25 |
permissions | -rw-r--r-- |
0 | 1 |
"""Set of HTML generic base views: |
2 |
||
3 |
* noresult, final |
|
4 |
* primary, sidebox |
|
5 |
* secondary, oneline, incontext, outofcontext, text |
|
6 |
* list |
|
7 |
* xml, rss |
|
8 |
||
9 |
||
10 |
:organization: Logilab |
|
479 | 11 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
0 | 12 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
13 |
""" |
|
964
a711c7c185d1
gargl, this shouldn't be there in case we're running py 2.4
sylvain.thenault@logilab.fr
parents:
958
diff
changeset
|
14 |
#from __future__ import with_statement |
958
6053622aae81
fix name error, filter out non empty rset
sylvain.thenault@logilab.fr
parents:
956
diff
changeset
|
15 |
|
0 | 16 |
__docformat__ = "restructuredtext en" |
17 |
||
528
60bd171ecd04
give row when selecting/dispatching content navigation component
sylvain.thenault@logilab.fr
parents:
479
diff
changeset
|
18 |
from warnings import warn |
0 | 19 |
from time import timezone |
20 |
||
21 |
from rql import nodes |
|
22 |
||
23 |
from logilab.common.decorators import cached |
|
530
9b56df97ec5f
fix xml views: ensure we're generating valide tag names (rsetxml), protect against control characters in xml view (should probably be generalized...)
sylvain.thenault@logilab.fr
parents:
528
diff
changeset
|
24 |
from logilab.mtconverter import TransformError, html_escape, xml_escape |
0 | 25 |
|
26 |
from cubicweb import Unauthorized, NoSelectableObject, typed_eid |
|
431 | 27 |
from cubicweb.common.selectors import (yes, nonempty_rset, accept, |
323 | 28 |
one_line_rset, match_search_state, |
431 | 29 |
match_form_params, accept_rset) |
0 | 30 |
from cubicweb.common.uilib import (cut, printable_value, UnicodeCSVWriter, |
530
9b56df97ec5f
fix xml views: ensure we're generating valide tag names (rsetxml), protect against control characters in xml view (should probably be generalized...)
sylvain.thenault@logilab.fr
parents:
528
diff
changeset
|
31 |
ajax_replace_url, rql_for_eid, simple_sgml_tag) |
0 | 32 |
from cubicweb.common.view import EntityView, AnyRsetView, EmptyRsetView |
33 |
from cubicweb.web.httpcache import MaxAgeHTTPCacheManager |
|
34 |
from cubicweb.web.views import vid_from_rset, linksearch_select_url, linksearch_match |
|
35 |
||
36 |
_ = unicode |
|
37 |
||
38 |
class NullView(AnyRsetView): |
|
39 |
"""default view when no result has been found""" |
|
40 |
id = 'null' |
|
237
3df2e0ae2eba
begin selector renaming (work in progress)
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
213
diff
changeset
|
41 |
__select__ = classmethod(yes) |
0 | 42 |
def call(self, **kwargs): |
43 |
pass |
|
44 |
cell_call = call |
|
45 |
||
46 |
||
47 |
class NoResultView(EmptyRsetView): |
|
48 |
"""default view when no result has been found""" |
|
49 |
id = 'noresult' |
|
50 |
||
51 |
def call(self, **kwargs): |
|
52 |
self.w(u'<div class="searchMessage"><strong>%s</strong></div>\n' |
|
53 |
% self.req._('No result matching query')) |
|
54 |
||
55 |
||
56 |
class FinalView(AnyRsetView): |
|
57 |
"""display values without any transformation (i.e. get a number for |
|
58 |
entities) |
|
59 |
""" |
|
60 |
id = 'final' |
|
978
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
61 |
# record generated i18n catalog messages |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
62 |
_('%d years') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
63 |
_('%d months') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
64 |
_('%d weeks') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
65 |
_('%d days') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
66 |
_('%d hours') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
67 |
_('%d minutes') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
68 |
_('%d seconds') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
69 |
_('%d years') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
70 |
_('%d months') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
71 |
_('%d weeks') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
72 |
_('%d days') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
73 |
_('%d hours') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
74 |
_('%d minutes') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
75 |
_('%d seconds') |
0 | 76 |
|
573
9c8fd72ba6c1
try to get raw text values in rset csv view
sylvain.thenault@logilab.fr
parents:
570
diff
changeset
|
77 |
def cell_call(self, row, col, props=None, displaytime=False, format='text/html'): |
0 | 78 |
etype = self.rset.description[row][col] |
79 |
value = self.rset.rows[row][col] |
|
80 |
if etype == 'String': |
|
81 |
entity, rtype = self.rset.related_entity(row, col) |
|
82 |
if entity is not None: |
|
83 |
# yes ! |
|
573
9c8fd72ba6c1
try to get raw text values in rset csv view
sylvain.thenault@logilab.fr
parents:
570
diff
changeset
|
84 |
self.w(entity.printable_value(rtype, value, format=format)) |
0 | 85 |
return |
86 |
if etype in ('Time', 'Interval'): |
|
87 |
# value is DateTimeDelta but we have no idea about what is the |
|
88 |
# reference date here, so we can only approximate years and months |
|
978
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
89 |
if format == 'text/html': |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
90 |
space = ' ' |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
91 |
else: |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
92 |
space = ' ' |
0 | 93 |
if value.days > 730: # 2 years |
978
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
94 |
self.w(self.req.__('%%d%syears' % space) % (value.days // 365)) |
0 | 95 |
elif value.days > 60: # 2 months |
978
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
96 |
self.w(self.req.__('%%d%smonths' % space) % (value.days // 30)) |
0 | 97 |
elif value.days > 14: # 2 weeks |
978
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
98 |
self.w(self.req.__('%%d%sweeks' % space) % (value.days // 7)) |
0 | 99 |
elif value.days > 2: |
978
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
100 |
self.w(self.req.__('%%d%sdays' % space) % int(value.days)) |
0 | 101 |
elif value.hours > 2: |
978
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
102 |
self.w(self.req.__('%%d%shours' % space) % int(value.hours)) |
0 | 103 |
elif value.minutes >= 2: |
978
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
104 |
self.w(self.req.__('%%d%sminutes' % space) % int(value.minutes)) |
0 | 105 |
else: |
978
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
106 |
self.w(self.req.__('%%d%sseconds' % space) % int(value.seconds)) |
0 | 107 |
return |
108 |
self.wdata(printable_value(self.req, etype, value, props, displaytime=displaytime)) |
|
109 |
||
110 |
||
111 |
class EditableFinalView(FinalView): |
|
112 |
"""same as FinalView but enables inplace-edition when possible""" |
|
113 |
id = 'editable-final' |
|
114 |
||
115 |
def cell_call(self, row, col, props=None, displaytime=False): |
|
116 |
etype = self.rset.description[row][col] |
|
117 |
value = self.rset.rows[row][col] |
|
118 |
entity, rtype = self.rset.related_entity(row, col) |
|
119 |
if entity is not None: |
|
120 |
self.w(entity.view('reledit', rtype=rtype)) |
|
121 |
else: |
|
122 |
super(EditableFinalView, self).cell_call(row, col, props, displaytime) |
|
123 |
||
124 |
PRIMARY_SKIP_RELS = set(['is', 'is_instance_of', 'identity', |
|
125 |
'owned_by', 'created_by', |
|
126 |
'in_state', 'wf_info_for', 'require_permission', |
|
127 |
'from_entity', 'to_entity', |
|
128 |
'see_also']) |
|
129 |
||
130 |
class PrimaryView(EntityView): |
|
131 |
"""the full view of an non final entity""" |
|
132 |
id = 'primary' |
|
133 |
title = _('primary') |
|
134 |
show_attr_label = True |
|
135 |
show_rel_label = True |
|
136 |
skip_none = True |
|
137 |
skip_attrs = ('eid', 'creation_date', 'modification_date') |
|
138 |
skip_rels = () |
|
139 |
main_related_section = True |
|
140 |
||
141 |
def html_headers(self): |
|
142 |
"""return a list of html headers (eg something to be inserted between |
|
143 |
<head> and </head> of the returned page |
|
144 |
||
145 |
by default primary views are indexed |
|
146 |
""" |
|
147 |
return [] |
|
148 |
||
149 |
def cell_call(self, row, col): |
|
150 |
self.row = row |
|
213
6842c3dee34b
adding files (formely appearing in jpl) specific to cubicweb
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
179
diff
changeset
|
151 |
# XXX move render_entity implementation here |
0 | 152 |
self.render_entity(self.complete_entity(row, col)) |
153 |
||
154 |
def render_entity(self, entity): |
|
155 |
"""return html to display the given entity""" |
|
156 |
siderelations = [] |
|
157 |
self.render_entity_title(entity) |
|
158 |
self.render_entity_metadata(entity) |
|
159 |
# entity's attributes and relations, excluding meta data |
|
160 |
# if the entity isn't meta itself |
|
988
b73f3cd23d43
remplacing tables by div for right (and left) box layout
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
978
diff
changeset
|
161 |
self.w(u'<div>') |
0 | 162 |
self.w(u'<div class="mainInfo">') |
163 |
self.render_entity_attributes(entity, siderelations) |
|
164 |
self.w(u'</div>') |
|
528
60bd171ecd04
give row when selecting/dispatching content navigation component
sylvain.thenault@logilab.fr
parents:
479
diff
changeset
|
165 |
self.content_navigation_components('navcontenttop') |
0 | 166 |
if self.main_related_section: |
167 |
self.render_entity_relations(entity, siderelations) |
|
988
b73f3cd23d43
remplacing tables by div for right (and left) box layout
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
978
diff
changeset
|
168 |
self.w(u'</div>') |
0 | 169 |
# side boxes |
988
b73f3cd23d43
remplacing tables by div for right (and left) box layout
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
978
diff
changeset
|
170 |
self.w(u'<div class="primaryRight">') |
0 | 171 |
self.render_side_related(entity, siderelations) |
988
b73f3cd23d43
remplacing tables by div for right (and left) box layout
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
978
diff
changeset
|
172 |
self.w(u'</div>') |
991
746fed01d1e0
correction (removing comments)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
988
diff
changeset
|
173 |
self.w(u'<div class="clear"></div>') |
528
60bd171ecd04
give row when selecting/dispatching content navigation component
sylvain.thenault@logilab.fr
parents:
479
diff
changeset
|
174 |
self.content_navigation_components('navcontentbottom') |
60bd171ecd04
give row when selecting/dispatching content navigation component
sylvain.thenault@logilab.fr
parents:
479
diff
changeset
|
175 |
|
60bd171ecd04
give row when selecting/dispatching content navigation component
sylvain.thenault@logilab.fr
parents:
479
diff
changeset
|
176 |
def content_navigation_components(self, context): |
60bd171ecd04
give row when selecting/dispatching content navigation component
sylvain.thenault@logilab.fr
parents:
479
diff
changeset
|
177 |
self.w(u'<div class="%s">' % context) |
0 | 178 |
for comp in self.vreg.possible_vobjects('contentnavigation', |
528
60bd171ecd04
give row when selecting/dispatching content navigation component
sylvain.thenault@logilab.fr
parents:
479
diff
changeset
|
179 |
self.req, self.rset, row=self.row, |
60bd171ecd04
give row when selecting/dispatching content navigation component
sylvain.thenault@logilab.fr
parents:
479
diff
changeset
|
180 |
view=self, context=context): |
60bd171ecd04
give row when selecting/dispatching content navigation component
sylvain.thenault@logilab.fr
parents:
479
diff
changeset
|
181 |
try: |
60bd171ecd04
give row when selecting/dispatching content navigation component
sylvain.thenault@logilab.fr
parents:
479
diff
changeset
|
182 |
comp.dispatch(w=self.w, row=self.row, view=self) |
60bd171ecd04
give row when selecting/dispatching content navigation component
sylvain.thenault@logilab.fr
parents:
479
diff
changeset
|
183 |
except NotImplementedError: |
60bd171ecd04
give row when selecting/dispatching content navigation component
sylvain.thenault@logilab.fr
parents:
479
diff
changeset
|
184 |
warn('component %s doesnt implement cell_call, please update' |
60bd171ecd04
give row when selecting/dispatching content navigation component
sylvain.thenault@logilab.fr
parents:
479
diff
changeset
|
185 |
% comp.__class__, DeprecationWarning) |
60bd171ecd04
give row when selecting/dispatching content navigation component
sylvain.thenault@logilab.fr
parents:
479
diff
changeset
|
186 |
comp.dispatch(w=self.w, view=self) |
0 | 187 |
self.w(u'</div>') |
528
60bd171ecd04
give row when selecting/dispatching content navigation component
sylvain.thenault@logilab.fr
parents:
479
diff
changeset
|
188 |
|
0 | 189 |
def iter_attributes(self, entity): |
190 |
for rschema, targetschema in entity.e_schema.attribute_definitions(): |
|
191 |
attr = rschema.type |
|
192 |
if attr in self.skip_attrs: |
|
193 |
continue |
|
194 |
yield rschema, targetschema |
|
195 |
||
196 |
def iter_relations(self, entity): |
|
197 |
skip = set(self.skip_rels) |
|
198 |
skip.update(PRIMARY_SKIP_RELS) |
|
199 |
for rschema, targetschemas, x in entity.e_schema.relation_definitions(): |
|
200 |
if rschema.type in skip: |
|
201 |
continue |
|
202 |
yield rschema, targetschemas, x |
|
203 |
||
204 |
def render_entity_title(self, entity): |
|
205 |
title = self.content_title(entity) # deprecate content_title? |
|
206 |
if title: |
|
207 |
self.w(u'<h1><span class="etype">%s</span> %s</h1>' |
|
208 |
% (entity.dc_type().capitalize(), title)) |
|
209 |
||
210 |
def content_title(self, entity): |
|
211 |
"""default implementation return an empty string""" |
|
212 |
return u'' |
|
213 |
||
214 |
def render_entity_metadata(self, entity): |
|
215 |
entity.view('metadata', w=self.w) |
|
216 |
summary = self.summary(entity) # deprecate summary? |
|
217 |
if summary: |
|
218 |
self.w(u'<div class="summary">%s</div>' % summary) |
|
219 |
||
220 |
def summary(self, entity): |
|
221 |
"""default implementation return an empty string""" |
|
179 | 222 |
return u'' |
0 | 223 |
|
224 |
def render_entity_attributes(self, entity, siderelations): |
|
225 |
for rschema, targetschema in self.iter_attributes(entity): |
|
226 |
attr = rschema.type |
|
227 |
if targetschema.type in ('Password', 'Bytes'): |
|
228 |
continue |
|
229 |
try: |
|
230 |
wdg = entity.get_widget(attr) |
|
231 |
except Exception, ex: |
|
232 |
value = entity.printable_value(attr, entity[attr], targetschema.type) |
|
233 |
else: |
|
234 |
value = wdg.render(entity) |
|
235 |
if self.skip_none and (value is None or value == ''): |
|
236 |
continue |
|
237 |
if rschema.meta: |
|
238 |
continue |
|
239 |
self._render_related_entities(entity, rschema, value) |
|
240 |
||
241 |
def render_entity_relations(self, entity, siderelations): |
|
242 |
if hasattr(self, 'get_side_boxes_defs'): |
|
243 |
return |
|
244 |
eschema = entity.e_schema |
|
245 |
maxrelated = self.req.property_value('navigation.related-limit') |
|
246 |
for rschema, targetschemas, x in self.iter_relations(entity): |
|
247 |
try: |
|
248 |
related = entity.related(rschema.type, x, limit=maxrelated+1) |
|
249 |
except Unauthorized: |
|
250 |
continue |
|
251 |
if not related: |
|
252 |
continue |
|
253 |
if self.is_side_related(rschema, eschema): |
|
254 |
siderelations.append((rschema, related, x)) |
|
255 |
continue |
|
256 |
self._render_related_entities(entity, rschema, related, x) |
|
257 |
||
258 |
def render_side_related(self, entity, siderelations): |
|
259 |
"""display side related relations: |
|
260 |
non-meta in a first step, meta in a second step |
|
261 |
""" |
|
262 |
if hasattr(self, 'get_side_boxes_defs'): |
|
958
6053622aae81
fix name error, filter out non empty rset
sylvain.thenault@logilab.fr
parents:
956
diff
changeset
|
263 |
sideboxes = [(label, rset) for label, rset in self.get_side_boxes_defs(entity) |
6053622aae81
fix name error, filter out non empty rset
sylvain.thenault@logilab.fr
parents:
956
diff
changeset
|
264 |
if rset] |
6053622aae81
fix name error, filter out non empty rset
sylvain.thenault@logilab.fr
parents:
956
diff
changeset
|
265 |
if sideboxes: |
6053622aae81
fix name error, filter out non empty rset
sylvain.thenault@logilab.fr
parents:
956
diff
changeset
|
266 |
for label, rset in sideboxes: |
0 | 267 |
self.w(u'<div class="sideRelated">') |
268 |
self.wview('sidebox', rset, title=label) |
|
269 |
self.w(u'</div>') |
|
270 |
elif siderelations: |
|
271 |
self.w(u'<div class="sideRelated">') |
|
272 |
for relatedinfos in siderelations: |
|
273 |
# if not relatedinfos[0].meta: |
|
274 |
# continue |
|
275 |
self._render_related_entities(entity, *relatedinfos) |
|
276 |
self.w(u'</div>') |
|
953
ded89d49c0b4
xhtml fixes: table has no align attribute, avoid inserting empty table
sylvain.thenault@logilab.fr
parents:
925
diff
changeset
|
277 |
boxes = list(self.vreg.possible_vobjects('boxes', self.req, self.rset, |
ded89d49c0b4
xhtml fixes: table has no align attribute, avoid inserting empty table
sylvain.thenault@logilab.fr
parents:
925
diff
changeset
|
278 |
row=self.row, view=self, |
ded89d49c0b4
xhtml fixes: table has no align attribute, avoid inserting empty table
sylvain.thenault@logilab.fr
parents:
925
diff
changeset
|
279 |
context='incontext')) |
ded89d49c0b4
xhtml fixes: table has no align attribute, avoid inserting empty table
sylvain.thenault@logilab.fr
parents:
925
diff
changeset
|
280 |
if boxes: |
ded89d49c0b4
xhtml fixes: table has no align attribute, avoid inserting empty table
sylvain.thenault@logilab.fr
parents:
925
diff
changeset
|
281 |
for box in boxes: |
ded89d49c0b4
xhtml fixes: table has no align attribute, avoid inserting empty table
sylvain.thenault@logilab.fr
parents:
925
diff
changeset
|
282 |
try: |
ded89d49c0b4
xhtml fixes: table has no align attribute, avoid inserting empty table
sylvain.thenault@logilab.fr
parents:
925
diff
changeset
|
283 |
box.dispatch(w=self.w, row=self.row) |
ded89d49c0b4
xhtml fixes: table has no align attribute, avoid inserting empty table
sylvain.thenault@logilab.fr
parents:
925
diff
changeset
|
284 |
except NotImplementedError: |
ded89d49c0b4
xhtml fixes: table has no align attribute, avoid inserting empty table
sylvain.thenault@logilab.fr
parents:
925
diff
changeset
|
285 |
# much probably a context insensitive box, which only implements |
ded89d49c0b4
xhtml fixes: table has no align attribute, avoid inserting empty table
sylvain.thenault@logilab.fr
parents:
925
diff
changeset
|
286 |
# .call() and not cell_call() |
991
746fed01d1e0
correction (removing comments)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
988
diff
changeset
|
287 |
box.dispatch(w=self.w) |
0 | 288 |
|
289 |
def is_side_related(self, rschema, eschema): |
|
290 |
return rschema.meta and \ |
|
291 |
not rschema.schema_relation() == eschema.schema_entity() |
|
292 |
||
293 |
def _render_related_entities(self, entity, rschema, related, |
|
294 |
role='subject'): |
|
295 |
if rschema.is_final(): |
|
296 |
value = related |
|
297 |
show_label = self.show_attr_label |
|
298 |
else: |
|
299 |
if not related: |
|
300 |
return |
|
301 |
show_label = self.show_rel_label |
|
302 |
# if not too many entities, show them all in a list |
|
303 |
maxrelated = self.req.property_value('navigation.related-limit') |
|
304 |
if related.rowcount <= maxrelated: |
|
305 |
if related.rowcount == 1: |
|
306 |
value = self.view('incontext', related, row=0) |
|
307 |
elif 1 < related.rowcount <= 5: |
|
308 |
value = self.view('csv', related) |
|
309 |
else: |
|
310 |
value = '<div>' + self.view('simplelist', related) + '</div>' |
|
311 |
# else show links to display related entities |
|
312 |
else: |
|
313 |
rql = related.printable_rql() |
|
314 |
related.limit(maxrelated) |
|
315 |
value = '<div>' + self.view('simplelist', related) |
|
316 |
value += '[<a href="%s">%s</a>]' % (self.build_url(rql=rql), |
|
317 |
self.req._('see them all')) |
|
318 |
value += '</div>' |
|
319 |
label = display_name(self.req, rschema.type, role) |
|
320 |
self.field(label, value, show_label=show_label, w=self.w, tr=False) |
|
321 |
||
322 |
||
323 |
class SideBoxView(EntityView): |
|
324 |
"""side box usually displaying some related entities in a primary view""" |
|
325 |
id = 'sidebox' |
|
326 |
||
327 |
def call(self, boxclass='sideBox', title=u''): |
|
328 |
"""display a list of entities by calling their <item_vid> view |
|
329 |
""" |
|
330 |
if title: |
|
331 |
self.w(u'<div class="sideBoxTitle"><span>%s</span></div>' % title) |
|
332 |
self.w(u'<div class="%s"><div class="sideBoxBody">' % boxclass) |
|
333 |
# if not too much entities, show them all in a list |
|
334 |
maxrelated = self.req.property_value('navigation.related-limit') |
|
335 |
if self.rset.rowcount <= maxrelated: |
|
336 |
if len(self.rset) == 1: |
|
337 |
self.wview('incontext', self.rset, row=0) |
|
338 |
elif 1 < len(self.rset) < 5: |
|
339 |
self.wview('csv', self.rset) |
|
340 |
else: |
|
341 |
self.wview('simplelist', self.rset) |
|
342 |
# else show links to display related entities |
|
343 |
else: |
|
344 |
self.rset.limit(maxrelated) |
|
345 |
rql = self.rset.printable_rql(encoded=False) |
|
346 |
self.wview('simplelist', self.rset) |
|
347 |
self.w(u'[<a href="%s">%s</a>]' % (self.build_url(rql=rql), |
|
348 |
self.req._('see them all'))) |
|
349 |
self.w(u'</div>\n</div>\n') |
|
350 |
||
351 |
||
352 |
||
353 |
class SecondaryView(EntityView): |
|
354 |
id = 'secondary' |
|
355 |
title = _('secondary') |
|
356 |
||
357 |
def cell_call(self, row, col): |
|
358 |
"""the secondary view for an entity |
|
359 |
secondary = icon + view(oneline) |
|
360 |
""" |
|
361 |
entity = self.entity(row, col) |
|
362 |
self.w(u' ') |
|
363 |
self.wview('oneline', self.rset, row=row, col=col) |
|
364 |
||
365 |
class OneLineView(EntityView): |
|
366 |
id = 'oneline' |
|
367 |
title = _('oneline') |
|
368 |
||
369 |
def cell_call(self, row, col): |
|
370 |
"""the one line view for an entity: linked text view |
|
371 |
""" |
|
372 |
entity = self.entity(row, col) |
|
373 |
self.w(u'<a href="%s">' % html_escape(entity.absolute_url())) |
|
374 |
self.w(html_escape(self.view('text', self.rset, row=row, col=col))) |
|
375 |
self.w(u'</a>') |
|
376 |
||
377 |
class TextView(EntityView): |
|
532
ce3e94cbb074
specify content type for text views
sylvain.thenault@logilab.fr
parents:
531
diff
changeset
|
378 |
"""the simplest text view for an entity""" |
0 | 379 |
id = 'text' |
380 |
title = _('text') |
|
532
ce3e94cbb074
specify content type for text views
sylvain.thenault@logilab.fr
parents:
531
diff
changeset
|
381 |
content_type = 'text/plain' |
0 | 382 |
accepts = 'Any', |
383 |
def call(self, **kwargs): |
|
384 |
"""the view is called for an entire result set, by default loop |
|
385 |
other rows of the result set and call the same view on the |
|
386 |
particular row |
|
387 |
||
388 |
Views applicable on None result sets have to override this method |
|
389 |
""" |
|
390 |
rset = self.rset |
|
391 |
if rset is None: |
|
392 |
raise NotImplementedError, self |
|
393 |
for i in xrange(len(rset)): |
|
394 |
self.wview(self.id, rset, row=i, **kwargs) |
|
395 |
if len(rset) > 1: |
|
396 |
self.w(u"\n") |
|
397 |
||
398 |
def cell_call(self, row, col=0, **kwargs): |
|
399 |
entity = self.entity(row, col) |
|
400 |
self.w(cut(entity.dc_title(), |
|
401 |
self.req.property_value('navigation.short-line-size'))) |
|
402 |
||
137
7e45cf48c2f1
don't display additional owners in metadata, this is confusing
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
403 |
|
0 | 404 |
class MetaDataView(EntityView): |
405 |
"""paragraph view of some metadata""" |
|
406 |
id = 'metadata' |
|
407 |
accepts = 'Any', |
|
408 |
show_eid = True |
|
409 |
||
410 |
def cell_call(self, row, col): |
|
411 |
_ = self.req._ |
|
412 |
entity = self.entity(row, col) |
|
413 |
self.w(u'<div class="metadata">') |
|
414 |
if self.show_eid: |
|
415 |
self.w(u'#%s - ' % entity.eid) |
|
416 |
if entity.modification_date != entity.creation_date: |
|
417 |
self.w(u'<span>%s</span> ' % _('latest update on')) |
|
418 |
self.w(u'<span class="value">%s</span>, ' |
|
419 |
% self.format_date(entity.modification_date)) |
|
420 |
# entities from external source may not have a creation date (eg ldap) |
|
421 |
if entity.creation_date: |
|
422 |
self.w(u'<span>%s</span> ' % _('created on')) |
|
423 |
self.w(u'<span class="value">%s</span>' |
|
424 |
% self.format_date(entity.creation_date)) |
|
425 |
if entity.creator: |
|
426 |
self.w(u' <span>%s</span> ' % _('by')) |
|
427 |
self.w(u'<span class="value">%s</span>' % entity.creator.name()) |
|
428 |
self.w(u'</div>') |
|
429 |
||
430 |
||
431 |
# new default views for finner control in general views , to use instead of |
|
432 |
# oneline / secondary |
|
433 |
||
434 |
class InContextTextView(TextView): |
|
435 |
id = 'textincontext' |
|
436 |
title = None # not listed as a possible view |
|
437 |
def cell_call(self, row, col): |
|
438 |
entity = self.entity(row, col) |
|
439 |
self.w(entity.dc_title()) |
|
440 |
||
441 |
class OutOfContextTextView(InContextTextView): |
|
442 |
id = 'textoutofcontext' |
|
443 |
||
444 |
def cell_call(self, row, col): |
|
445 |
entity = self.entity(row, col) |
|
446 |
self.w(entity.dc_long_title()) |
|
447 |
||
448 |
||
449 |
class InContextView(EntityView): |
|
450 |
id = 'incontext' |
|
451 |
||
452 |
def cell_call(self, row, col): |
|
453 |
entity = self.entity(row, col) |
|
454 |
desc = cut(entity.dc_description(), 50) |
|
455 |
self.w(u'<a href="%s" title="%s">' % (html_escape(entity.absolute_url()), |
|
456 |
html_escape(desc))) |
|
457 |
self.w(html_escape(self.view('textincontext', self.rset, row=row, col=col))) |
|
458 |
self.w(u'</a>') |
|
459 |
||
460 |
||
461 |
class OutOfContextView(EntityView): |
|
462 |
id = 'outofcontext' |
|
463 |
||
464 |
def cell_call(self, row, col): |
|
465 |
self.w(u'<a href="%s">' % self.entity(row, col).absolute_url()) |
|
466 |
self.w(html_escape(self.view('textoutofcontext', self.rset, row=row, col=col))) |
|
467 |
self.w(u'</a>') |
|
468 |
||
469 |
class NotClickableInContextView(EntityView): |
|
470 |
id = 'incontext' |
|
471 |
accepts = ('State',) |
|
472 |
def cell_call(self, row, col): |
|
473 |
self.w(html_escape(self.view('textincontext', self.rset, row=row, col=col))) |
|
474 |
||
475 |
## class NotClickableOutOfContextView(EntityView): |
|
476 |
## id = 'outofcontext' |
|
477 |
## accepts = ('State',) |
|
478 |
## def cell_call(self, row, col): |
|
479 |
## self.w(html_escape(self.view('textoutofcontext', self.rset, row=row))) |
|
480 |
||
481 |
||
482 |
# list and table related views ################################################ |
|
483 |
||
484 |
class ListView(EntityView): |
|
485 |
id = 'list' |
|
486 |
title = _('list') |
|
487 |
item_vid = 'listitem' |
|
488 |
||
489 |
def call(self, klass=None, title=None, subvid=None, listid=None, **kwargs): |
|
490 |
"""display a list of entities by calling their <item_vid> view |
|
491 |
|
|
492 |
:param listid: the DOM id to use for the root element |
|
493 |
""" |
|
494 |
if subvid is None and 'subvid' in self.req.form: |
|
495 |
subvid = self.req.form.pop('subvid') # consume it |
|
496 |
if listid: |
|
497 |
listid = u' id="%s"' % listid |
|
498 |
else: |
|
499 |
listid = u'' |
|
500 |
if title: |
|
501 |
self.w(u'<div%s class="%s"><h4>%s</h4>\n' % (listid, klass or 'section', title)) |
|
502 |
self.w(u'<ul>\n') |
|
503 |
else: |
|
504 |
self.w(u'<ul%s class="%s">\n' % (listid, klass or 'section')) |
|
505 |
for i in xrange(self.rset.rowcount): |
|
506 |
self.cell_call(row=i, col=0, vid=subvid, **kwargs) |
|
507 |
self.w(u'</ul>\n') |
|
508 |
if title: |
|
509 |
self.w(u'</div>\n') |
|
510 |
||
511 |
def cell_call(self, row, col=0, vid=None, **kwargs): |
|
512 |
self.w(u'<li>') |
|
513 |
self.wview(self.item_vid, self.rset, row=row, col=col, vid=vid, **kwargs) |
|
514 |
self.w(u'</li>\n') |
|
515 |
||
516 |
def url(self): |
|
517 |
"""overrides url method so that by default, the view list is called |
|
518 |
with sorted entities |
|
519 |
""" |
|
520 |
coltypes = self.rset.column_types(0) |
|
521 |
# don't want to generate the rql if there is some restriction on |
|
522 |
# something else than the entity type |
|
523 |
if len(coltypes) == 1: |
|
524 |
# XXX norestriction is not correct here. For instance, in cases like |
|
525 |
# Any P,N WHERE P is Project, P name N |
|
526 |
# norestriction should equal True |
|
527 |
restr = self.rset.syntax_tree().children[0].where |
|
528 |
norestriction = (isinstance(restr, nodes.Relation) and |
|
529 |
restr.is_types_restriction()) |
|
530 |
if norestriction: |
|
531 |
etype = iter(coltypes).next() |
|
532 |
return self.build_url(etype.lower(), vid=self.id) |
|
533 |
if len(self.rset) == 1: |
|
534 |
entity = self.rset.get_entity(0, 0) |
|
535 |
return self.build_url(entity.rest_path(), vid=self.id) |
|
536 |
return self.build_url(rql=self.rset.printable_rql(), vid=self.id) |
|
537 |
||
538 |
||
539 |
class ListItemView(EntityView): |
|
540 |
id = 'listitem' |
|
541 |
||
542 |
@property |
|
543 |
def redirect_vid(self): |
|
544 |
if self.req.search_state[0] == 'normal': |
|
545 |
return 'outofcontext' |
|
546 |
return 'outofcontext-search' |
|
547 |
||
548 |
def cell_call(self, row, col, vid=None, **kwargs): |
|
549 |
if not vid: |
|
550 |
vid = self.redirect_vid |
|
551 |
try: |
|
552 |
self.wview(vid, self.rset, row=row, col=col, **kwargs) |
|
553 |
except NoSelectableObject: |
|
554 |
if vid == self.redirect_vid: |
|
555 |
raise |
|
556 |
self.wview(self.redirect_vid, self.rset, row=row, col=col, **kwargs) |
|
557 |
||
558 |
||
559 |
class SimpleListView(ListItemView): |
|
560 |
"""list without bullets""" |
|
561 |
id = 'simplelist' |
|
562 |
redirect_vid = 'incontext' |
|
563 |
||
564 |
||
565 |
class CSVView(SimpleListView): |
|
566 |
id = 'csv' |
|
567 |
redirect_vid = 'incontext' |
|
568 |
||
569 |
def call(self, **kwargs): |
|
570 |
rset = self.rset |
|
571 |
for i in xrange(len(rset)): |
|
572 |
self.cell_call(i, 0, vid=kwargs.get('vid')) |
|
573 |
if i < rset.rowcount-1: |
|
574 |
self.w(u", ") |
|
575 |
||
576 |
||
577 |
class TreeItemView(ListItemView): |
|
578 |
accepts = ('Any',) |
|
579 |
id = 'treeitem' |
|
580 |
||
581 |
def cell_call(self, row, col): |
|
582 |
self.wview('incontext', self.rset, row=row, col=col) |
|
583 |
||
584 |
||
585 |
# xml and xml/rss views ####################################################### |
|
586 |
||
587 |
class XmlView(EntityView): |
|
588 |
id = 'xml' |
|
589 |
title = _('xml') |
|
590 |
templatable = False |
|
591 |
content_type = 'text/xml' |
|
592 |
xml_root = 'rset' |
|
593 |
item_vid = 'xmlitem' |
|
594 |
||
595 |
def cell_call(self, row, col): |
|
596 |
self.wview(self.item_vid, self.rset, row=row, col=col) |
|
597 |
||
598 |
def call(self): |
|
530
9b56df97ec5f
fix xml views: ensure we're generating valide tag names (rsetxml), protect against control characters in xml view (should probably be generalized...)
sylvain.thenault@logilab.fr
parents:
528
diff
changeset
|
599 |
"""display a list of entities by calling their <item_vid> view""" |
0 | 600 |
self.w(u'<?xml version="1.0" encoding="%s"?>\n' % self.req.encoding) |
601 |
self.w(u'<%s size="%s">\n' % (self.xml_root, len(self.rset))) |
|
602 |
for i in xrange(self.rset.rowcount): |
|
603 |
self.cell_call(i, 0) |
|
604 |
self.w(u'</%s>\n' % self.xml_root) |
|
605 |
||
606 |
||
607 |
class XmlItemView(EntityView): |
|
608 |
id = 'xmlitem' |
|
609 |
||
610 |
def cell_call(self, row, col): |
|
611 |
""" element as an item for an xml feed """ |
|
612 |
entity = self.complete_entity(row, col) |
|
613 |
self.w(u'<%s>\n' % (entity.e_schema)) |
|
614 |
for rschema, attrschema in entity.e_schema.attribute_definitions(): |
|
615 |
attr = rschema.type |
|
616 |
try: |
|
617 |
value = entity[attr] |
|
618 |
except KeyError: |
|
619 |
# Bytes |
|
620 |
continue |
|
621 |
if value is not None: |
|
622 |
if attrschema == 'Bytes': |
|
623 |
from base64 import b64encode |
|
624 |
value = '<![CDATA[%s]]>' % b64encode(value.getvalue()) |
|
625 |
elif isinstance(value, basestring): |
|
530
9b56df97ec5f
fix xml views: ensure we're generating valide tag names (rsetxml), protect against control characters in xml view (should probably be generalized...)
sylvain.thenault@logilab.fr
parents:
528
diff
changeset
|
626 |
value = xml_escape(value) |
0 | 627 |
self.w(u' <%s>%s</%s>\n' % (attr, value, attr)) |
628 |
self.w(u'</%s>\n' % (entity.e_schema)) |
|
629 |
||
630 |
||
369
c8a6edc224bb
new rsetxml view, reusing most code from csvexport view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
349
diff
changeset
|
631 |
|
c8a6edc224bb
new rsetxml view, reusing most code from csvexport view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
349
diff
changeset
|
632 |
class XMLRsetView(AnyRsetView): |
c8a6edc224bb
new rsetxml view, reusing most code from csvexport view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
349
diff
changeset
|
633 |
"""dumps xml in CSV""" |
c8a6edc224bb
new rsetxml view, reusing most code from csvexport view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
349
diff
changeset
|
634 |
id = 'rsetxml' |
c8a6edc224bb
new rsetxml view, reusing most code from csvexport view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
349
diff
changeset
|
635 |
title = _('xml export') |
c8a6edc224bb
new rsetxml view, reusing most code from csvexport view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
349
diff
changeset
|
636 |
templatable = False |
c8a6edc224bb
new rsetxml view, reusing most code from csvexport view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
349
diff
changeset
|
637 |
content_type = 'text/xml' |
c8a6edc224bb
new rsetxml view, reusing most code from csvexport view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
349
diff
changeset
|
638 |
xml_root = 'rset' |
c8a6edc224bb
new rsetxml view, reusing most code from csvexport view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
349
diff
changeset
|
639 |
|
c8a6edc224bb
new rsetxml view, reusing most code from csvexport view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
349
diff
changeset
|
640 |
def call(self): |
c8a6edc224bb
new rsetxml view, reusing most code from csvexport view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
349
diff
changeset
|
641 |
w = self.w |
370
7e76f651314b
fix rset xml view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
369
diff
changeset
|
642 |
rset, descr = self.rset, self.rset.description |
7e76f651314b
fix rset xml view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
369
diff
changeset
|
643 |
eschema = self.schema.eschema |
7e76f651314b
fix rset xml view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
369
diff
changeset
|
644 |
labels = self.columns_labels(False) |
369
c8a6edc224bb
new rsetxml view, reusing most code from csvexport view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
349
diff
changeset
|
645 |
w(u'<?xml version="1.0" encoding="%s"?>\n' % self.req.encoding) |
530
9b56df97ec5f
fix xml views: ensure we're generating valide tag names (rsetxml), protect against control characters in xml view (should probably be generalized...)
sylvain.thenault@logilab.fr
parents:
528
diff
changeset
|
646 |
w(u'<%s query="%s">\n' % (self.xml_root, html_escape(rset.printable_rql()))) |
369
c8a6edc224bb
new rsetxml view, reusing most code from csvexport view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
349
diff
changeset
|
647 |
for rowindex, row in enumerate(self.rset): |
c8a6edc224bb
new rsetxml view, reusing most code from csvexport view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
349
diff
changeset
|
648 |
w(u' <row>\n') |
c8a6edc224bb
new rsetxml view, reusing most code from csvexport view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
349
diff
changeset
|
649 |
for colindex, val in enumerate(row): |
370
7e76f651314b
fix rset xml view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
369
diff
changeset
|
650 |
etype = descr[rowindex][colindex] |
369
c8a6edc224bb
new rsetxml view, reusing most code from csvexport view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
349
diff
changeset
|
651 |
tag = labels[colindex] |
530
9b56df97ec5f
fix xml views: ensure we're generating valide tag names (rsetxml), protect against control characters in xml view (should probably be generalized...)
sylvain.thenault@logilab.fr
parents:
528
diff
changeset
|
652 |
attrs = {} |
9b56df97ec5f
fix xml views: ensure we're generating valide tag names (rsetxml), protect against control characters in xml view (should probably be generalized...)
sylvain.thenault@logilab.fr
parents:
528
diff
changeset
|
653 |
if '(' in tag: |
9b56df97ec5f
fix xml views: ensure we're generating valide tag names (rsetxml), protect against control characters in xml view (should probably be generalized...)
sylvain.thenault@logilab.fr
parents:
528
diff
changeset
|
654 |
attrs['expr'] = tag |
9b56df97ec5f
fix xml views: ensure we're generating valide tag names (rsetxml), protect against control characters in xml view (should probably be generalized...)
sylvain.thenault@logilab.fr
parents:
528
diff
changeset
|
655 |
tag = 'funccall' |
370
7e76f651314b
fix rset xml view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
369
diff
changeset
|
656 |
if val is not None and not eschema(etype).is_final(): |
530
9b56df97ec5f
fix xml views: ensure we're generating valide tag names (rsetxml), protect against control characters in xml view (should probably be generalized...)
sylvain.thenault@logilab.fr
parents:
528
diff
changeset
|
657 |
attrs['eid'] = val |
370
7e76f651314b
fix rset xml view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
369
diff
changeset
|
658 |
# csvrow.append(val) # val is eid in that case |
530
9b56df97ec5f
fix xml views: ensure we're generating valide tag names (rsetxml), protect against control characters in xml view (should probably be generalized...)
sylvain.thenault@logilab.fr
parents:
528
diff
changeset
|
659 |
val = self.view('textincontext', rset, |
9b56df97ec5f
fix xml views: ensure we're generating valide tag names (rsetxml), protect against control characters in xml view (should probably be generalized...)
sylvain.thenault@logilab.fr
parents:
528
diff
changeset
|
660 |
row=rowindex, col=colindex) |
370
7e76f651314b
fix rset xml view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
369
diff
changeset
|
661 |
else: |
530
9b56df97ec5f
fix xml views: ensure we're generating valide tag names (rsetxml), protect against control characters in xml view (should probably be generalized...)
sylvain.thenault@logilab.fr
parents:
528
diff
changeset
|
662 |
val = self.view('final', rset, displaytime=True, |
573
9c8fd72ba6c1
try to get raw text values in rset csv view
sylvain.thenault@logilab.fr
parents:
570
diff
changeset
|
663 |
row=rowindex, col=colindex, format='text/plain') |
530
9b56df97ec5f
fix xml views: ensure we're generating valide tag names (rsetxml), protect against control characters in xml view (should probably be generalized...)
sylvain.thenault@logilab.fr
parents:
528
diff
changeset
|
664 |
w(simple_sgml_tag(tag, val, **attrs)) |
369
c8a6edc224bb
new rsetxml view, reusing most code from csvexport view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
349
diff
changeset
|
665 |
w(u' </row>\n') |
c8a6edc224bb
new rsetxml view, reusing most code from csvexport view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
349
diff
changeset
|
666 |
w(u'</%s>\n' % self.xml_root) |
c8a6edc224bb
new rsetxml view, reusing most code from csvexport view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
349
diff
changeset
|
667 |
|
c8a6edc224bb
new rsetxml view, reusing most code from csvexport view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
349
diff
changeset
|
668 |
|
0 | 669 |
class RssView(XmlView): |
670 |
id = 'rss' |
|
671 |
title = _('rss') |
|
672 |
templatable = False |
|
673 |
content_type = 'text/xml' |
|
674 |
http_cache_manager = MaxAgeHTTPCacheManager |
|
675 |
cache_max_age = 60*60*2 # stay in http cache for 2 hours by default |
|
1194
e224f064a268
optimize this code part
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1140
diff
changeset
|
676 |
|
e224f064a268
optimize this code part
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1140
diff
changeset
|
677 |
def _open(self): |
0 | 678 |
req = self.req |
679 |
self.w(u'<?xml version="1.0" encoding="%s"?>\n' % req.encoding) |
|
1125
1fbeb11a27a3
refactoring RssItemView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
991
diff
changeset
|
680 |
self.w(u'''<rss version="2.0" |
0 | 681 |
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
682 |
xmlns:dc="http://purl.org/dc/elements/1.1/" |
|
683 |
>''') |
|
684 |
self.w(u' <channel rdf:about="%s">\n' % html_escape(req.url())) |
|
685 |
self.w(u' <title>%s RSS Feed</title>\n' % html_escape(self.page_title())) |
|
686 |
self.w(u' <description>%s</description>\n' % html_escape(req.form.get('vtitle', ''))) |
|
687 |
params = req.form.copy() |
|
688 |
params.pop('vid', None) |
|
689 |
self.w(u' <link>%s</link>\n' % html_escape(self.build_url(**params))) |
|
1194
e224f064a268
optimize this code part
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1140
diff
changeset
|
690 |
|
e224f064a268
optimize this code part
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1140
diff
changeset
|
691 |
def _close(self): |
e224f064a268
optimize this code part
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1140
diff
changeset
|
692 |
self.w(u' </channel>\n') |
e224f064a268
optimize this code part
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1140
diff
changeset
|
693 |
self.w(u'</rss>') |
e224f064a268
optimize this code part
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1140
diff
changeset
|
694 |
|
e224f064a268
optimize this code part
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1140
diff
changeset
|
695 |
def call(self): |
e224f064a268
optimize this code part
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1140
diff
changeset
|
696 |
"""display a list of entities by calling their <item_vid> view""" |
e224f064a268
optimize this code part
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1140
diff
changeset
|
697 |
self._open() |
0 | 698 |
for i in xrange(self.rset.rowcount): |
699 |
self.cell_call(i, 0) |
|
1194
e224f064a268
optimize this code part
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1140
diff
changeset
|
700 |
self._close() |
e224f064a268
optimize this code part
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1140
diff
changeset
|
701 |
|
e224f064a268
optimize this code part
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1140
diff
changeset
|
702 |
def cell_call(self, row, col): |
e224f064a268
optimize this code part
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1140
diff
changeset
|
703 |
self.wview('rssitem', self.rset, row=row, col=col) |
0 | 704 |
|
705 |
class RssItemView(EntityView): |
|
706 |
id = 'rssitem' |
|
707 |
date_format = '%%Y-%%m-%%dT%%H:%%M%+03i:00' % (timezone / 3600) |
|
1194
e224f064a268
optimize this code part
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1140
diff
changeset
|
708 |
add_div_section = False |
0 | 709 |
|
710 |
def cell_call(self, row, col): |
|
711 |
entity = self.complete_entity(row, col) |
|
712 |
self.w(u'<item rdf:about="%s">\n' % html_escape(entity.absolute_url())) |
|
1125
1fbeb11a27a3
refactoring RssItemView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
991
diff
changeset
|
713 |
self.render_title_link(entity) |
1140
79bcbb1c39ce
please stop/read carefully dumb copy / past
sylvain.thenault@logilab.fr
parents:
1139
diff
changeset
|
714 |
self._marker('description', html_escape(entity.dc_description())) |
1125
1fbeb11a27a3
refactoring RssItemView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
991
diff
changeset
|
715 |
self._marker('dc:date', entity.dc_date(self.date_format)) |
1fbeb11a27a3
refactoring RssItemView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
991
diff
changeset
|
716 |
self.render_entity_creator(entity) |
1fbeb11a27a3
refactoring RssItemView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
991
diff
changeset
|
717 |
self.w(u'</item>\n') |
1fbeb11a27a3
refactoring RssItemView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
991
diff
changeset
|
718 |
|
1fbeb11a27a3
refactoring RssItemView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
991
diff
changeset
|
719 |
def render_title_link(self, entity): |
0 | 720 |
self._marker('title', entity.dc_long_title()) |
721 |
self._marker('link', entity.absolute_url()) |
|
1125
1fbeb11a27a3
refactoring RssItemView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
991
diff
changeset
|
722 |
|
1fbeb11a27a3
refactoring RssItemView.
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
991
diff
changeset
|
723 |
def render_entity_creator(self, entity): |
324
9b51dac0bac2
fix author tag
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
323
diff
changeset
|
724 |
if entity.creator: |
1139
bf3384eb87a4
try to fix rss feed, but author still does'nt show up...
sylvain.thenault@logilab.fr
parents:
1125
diff
changeset
|
725 |
self._marker('dc:creator', entity.creator.name()) |
324
9b51dac0bac2
fix author tag
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
323
diff
changeset
|
726 |
email = entity.creator.get_email() |
9b51dac0bac2
fix author tag
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
323
diff
changeset
|
727 |
if email: |
1139
bf3384eb87a4
try to fix rss feed, but author still does'nt show up...
sylvain.thenault@logilab.fr
parents:
1125
diff
changeset
|
728 |
self.w(u'<author>') |
bf3384eb87a4
try to fix rss feed, but author still does'nt show up...
sylvain.thenault@logilab.fr
parents:
1125
diff
changeset
|
729 |
self.w(email) |
bf3384eb87a4
try to fix rss feed, but author still does'nt show up...
sylvain.thenault@logilab.fr
parents:
1125
diff
changeset
|
730 |
self.w(u'</author>') |
0 | 731 |
|
732 |
def _marker(self, marker, value): |
|
733 |
if value: |
|
734 |
self.w(u' <%s>%s</%s>\n' % (marker, html_escape(value), marker)) |
|
735 |
||
736 |
class CSVMixIn(object): |
|
737 |
"""mixin class for CSV views""" |
|
738 |
templatable = False |
|
739 |
content_type = "text/comma-separated-values" |
|
740 |
binary = True # avoid unicode assertion |
|
741 |
csv_params = {'dialect': 'excel', |
|
742 |
'quotechar': '"', |
|
743 |
'delimiter': ';', |
|
744 |
'lineterminator': '\n'} |
|
745 |
||
746 |
def set_request_content_type(self): |
|
747 |
"""overriden to set a .csv filename""" |
|
748 |
self.req.set_content_type(self.content_type, filename='cubicwebexport.csv') |
|
749 |
||
750 |
def csvwriter(self, **kwargs): |
|
751 |
params = self.csv_params.copy() |
|
752 |
params.update(kwargs) |
|
753 |
return UnicodeCSVWriter(self.w, self.req.encoding, **params) |
|
754 |
||
755 |
||
756 |
class CSVRsetView(CSVMixIn, AnyRsetView): |
|
757 |
"""dumps rset in CSV""" |
|
758 |
id = 'csvexport' |
|
759 |
title = _('csv export') |
|
760 |
||
761 |
def call(self): |
|
762 |
writer = self.csvwriter() |
|
369
c8a6edc224bb
new rsetxml view, reusing most code from csvexport view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
349
diff
changeset
|
763 |
writer.writerow(self.columns_labels()) |
370
7e76f651314b
fix rset xml view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
369
diff
changeset
|
764 |
rset, descr = self.rset, self.rset.description |
7e76f651314b
fix rset xml view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
369
diff
changeset
|
765 |
eschema = self.schema.eschema |
7e76f651314b
fix rset xml view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
369
diff
changeset
|
766 |
for rowindex, row in enumerate(rset): |
0 | 767 |
csvrow = [] |
768 |
for colindex, val in enumerate(row): |
|
370
7e76f651314b
fix rset xml view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
369
diff
changeset
|
769 |
etype = descr[rowindex][colindex] |
7e76f651314b
fix rset xml view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
369
diff
changeset
|
770 |
if val is not None and not eschema(etype).is_final(): |
7e76f651314b
fix rset xml view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
369
diff
changeset
|
771 |
# csvrow.append(val) # val is eid in that case |
7e76f651314b
fix rset xml view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
369
diff
changeset
|
772 |
content = self.view('textincontext', rset, |
7e76f651314b
fix rset xml view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
369
diff
changeset
|
773 |
row=rowindex, col=colindex) |
7e76f651314b
fix rset xml view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
369
diff
changeset
|
774 |
else: |
573
9c8fd72ba6c1
try to get raw text values in rset csv view
sylvain.thenault@logilab.fr
parents:
570
diff
changeset
|
775 |
content = self.view('final', rset, |
9c8fd72ba6c1
try to get raw text values in rset csv view
sylvain.thenault@logilab.fr
parents:
570
diff
changeset
|
776 |
displaytime=True, format='text/plain', |
370
7e76f651314b
fix rset xml view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
369
diff
changeset
|
777 |
row=rowindex, col=colindex) |
0 | 778 |
csvrow.append(content) |
779 |
writer.writerow(csvrow) |
|
780 |
||
781 |
||
782 |
class CSVEntityView(CSVMixIn, EntityView): |
|
783 |
"""dumps rset's entities (with full set of attributes) in CSV""" |
|
784 |
id = 'ecsvexport' |
|
785 |
title = _('csv entities export') |
|
786 |
||
787 |
def call(self): |
|
788 |
""" |
|
789 |
the generated CSV file will have a table per entity type |
|
790 |
found in the resultset. ('table' here only means empty |
|
791 |
lines separation between table contents) |
|
792 |
""" |
|
793 |
req = self.req |
|
794 |
rows_by_type = {} |
|
795 |
writer = self.csvwriter() |
|
796 |
rowdef_by_type = {} |
|
797 |
for index in xrange(len(self.rset)): |
|
798 |
entity = self.complete_entity(index) |
|
799 |
if entity.e_schema not in rows_by_type: |
|
400
b05a36678265
'as' becomes a keyword when with statement activated
sylvain.thenault@logilab.fr
parents:
371
diff
changeset
|
800 |
rowdef_by_type[entity.e_schema] = [rs for rs, at in entity.e_schema.attribute_definitions() |
b05a36678265
'as' becomes a keyword when with statement activated
sylvain.thenault@logilab.fr
parents:
371
diff
changeset
|
801 |
if at != 'Bytes'] |
0 | 802 |
rows_by_type[entity.e_schema] = [[display_name(req, rschema.type) |
803 |
for rschema in rowdef_by_type[entity.e_schema]]] |
|
804 |
rows = rows_by_type[entity.e_schema] |
|
805 |
rows.append([entity.printable_value(rs.type, format='text/plain') |
|
806 |
for rs in rowdef_by_type[entity.e_schema]]) |
|
807 |
for etype, rows in rows_by_type.items(): |
|
808 |
writer.writerows(rows) |
|
809 |
# use two empty lines as separator |
|
810 |
writer.writerows([[], []]) |
|
811 |
||
812 |
||
813 |
## Work in progress ########################################################### |
|
814 |
||
815 |
class SearchForAssociationView(EntityView): |
|
816 |
"""view called by the edition view when the user asks |
|
817 |
to search for something to link to the edited eid |
|
818 |
""" |
|
819 |
id = 'search-associate' |
|
820 |
title = _('search for association') |
|
431 | 821 |
__selectors__ = (one_line_rset, match_search_state, accept) |
0 | 822 |
accepts = ('Any',) |
823 |
search_states = ('linksearch',) |
|
824 |
||
825 |
def cell_call(self, row, col): |
|
826 |
rset, vid, divid, paginate = self.filter_box_context_info() |
|
827 |
self.w(u'<div id="%s">' % divid) |
|
828 |
self.pagination(self.req, rset, w=self.w) |
|
608 | 829 |
self.wview(vid, rset, 'noresult') |
0 | 830 |
self.w(u'</div>') |
831 |
||
832 |
@cached |
|
833 |
def filter_box_context_info(self): |
|
834 |
entity = self.entity(0, 0) |
|
835 |
role, eid, rtype, etype = self.req.search_state[1] |
|
836 |
assert entity.eid == typed_eid(eid) |
|
837 |
# the default behaviour is to fetch all unrelated entities and display |
|
838 |
# them. Use fetch_order and not fetch_unrelated_order as sort method |
|
839 |
# since the latter is mainly there to select relevant items in the combo |
|
840 |
# box, it doesn't give interesting result in this context |
|
841 |
rql = entity.unrelated_rql(rtype, etype, role, |
|
842 |
ordermethod='fetch_order', |
|
843 |
vocabconstraints=False) |
|
844 |
rset = self.req.execute(rql, {'x' : entity.eid}, 'x') |
|
845 |
#vid = vid_from_rset(self.req, rset, self.schema) |
|
846 |
return rset, 'list', "search-associate-content", True |
|
847 |
||
848 |
||
849 |
class OutOfContextSearch(EntityView): |
|
850 |
id = 'outofcontext-search' |
|
851 |
def cell_call(self, row, col): |
|
852 |
entity = self.entity(row, col) |
|
853 |
erset = entity.as_rset() |
|
854 |
if linksearch_match(self.req, erset): |
|
855 |
self.w(u'<a href="%s" title="%s">%s</a> <a href="%s" title="%s">[...]</a>' % ( |
|
856 |
html_escape(linksearch_select_url(self.req, erset)), |
|
857 |
self.req._('select this entity'), |
|
858 |
html_escape(entity.view('textoutofcontext')), |
|
859 |
html_escape(entity.absolute_url(vid='primary')), |
|
860 |
self.req._('view detail for this entity'))) |
|
861 |
else: |
|
862 |
entity.view('outofcontext', w=self.w) |
|
863 |
||
864 |
||
865 |
class EditRelationView(EntityView): |
|
866 |
"""Note: This is work in progress |
|
867 |
||
868 |
This view is part of the edition view refactoring. |
|
869 |
It is still too big and cluttered with strange logic, but it's a start |
|
870 |
||
871 |
The main idea is to be able to call an edition view for a specific |
|
872 |
relation. For example : |
|
873 |
self.wview('editrelation', person_rset, rtype='firstname') |
|
874 |
self.wview('editrelation', person_rset, rtype='works_for') |
|
875 |
""" |
|
876 |
id = 'editrelation' |
|
877 |
||
431 | 878 |
__selectors__ = (match_form_params,) |
0 | 879 |
form_params = ('rtype',) |
880 |
||
881 |
# TODO: inlineview, multiple edit, (widget view ?) |
|
882 |
def cell_call(self, row, col, rtype=None, role='subject', targettype=None, |
|
883 |
showlabel=True): |
|
884 |
self.req.add_js( ('cubicweb.ajax.js', 'cubicweb.edition.js') ) |
|
885 |
entity = self.entity(row, col) |
|
886 |
rtype = self.req.form.get('rtype', rtype) |
|
887 |
showlabel = self.req.form.get('showlabel', showlabel) |
|
888 |
assert rtype is not None, "rtype is mandatory for 'edirelation' view" |
|
889 |
targettype = self.req.form.get('targettype', targettype) |
|
890 |
role = self.req.form.get('role', role) |
|
891 |
category = entity.rtags.get_category(rtype, targettype, role) |
|
570
0c9dfc430200
fix test (this view is not used actually...)
sylvain.thenault@logilab.fr
parents:
532
diff
changeset
|
892 |
if category in ('primary', 'secondary') or self.schema.rschema(rtype).is_final(): |
0 | 893 |
if hasattr(entity, '%s_format' % rtype): |
894 |
formatwdg = entity.get_widget('%s_format' % rtype, role) |
|
895 |
self.w(formatwdg.edit_render(entity)) |
|
896 |
self.w(u'<br/>') |
|
897 |
wdg = entity.get_widget(rtype, role) |
|
898 |
if showlabel: |
|
899 |
self.w(u'%s' % wdg.render_label(entity)) |
|
900 |
self.w(u'%s %s %s' % |
|
901 |
(wdg.render_error(entity), wdg.edit_render(entity), |
|
902 |
wdg.render_help(entity),)) |
|
570
0c9dfc430200
fix test (this view is not used actually...)
sylvain.thenault@logilab.fr
parents:
532
diff
changeset
|
903 |
else: |
0 | 904 |
self._render_generic_relation(entity, rtype, role) |
905 |
||
906 |
def _render_generic_relation(self, entity, relname, role): |
|
907 |
text = self.req.__('add %s %s %s' % (entity.e_schema, relname, role)) |
|
908 |
# pending operations |
|
909 |
operations = self.req.get_pending_operations(entity, relname, role) |
|
910 |
if operations['insert'] or operations['delete'] or 'unfold' in self.req.form: |
|
911 |
self.w(u'<h3>%s</h3>' % text) |
|
912 |
self._render_generic_relation_form(operations, entity, relname, role) |
|
913 |
else: |
|
914 |
divid = "%s%sreledit" % (relname, role) |
|
915 |
url = ajax_replace_url(divid, rql_for_eid(entity.eid), 'editrelation', |
|
916 |
{'unfold' : 1, 'relname' : relname, 'role' : role}) |
|
917 |
self.w(u'<a href="%s">%s</a>' % (url, text)) |
|
918 |
self.w(u'<div id="%s"></div>' % divid) |
|
919 |
||
920 |
||
921 |
def _build_opvalue(self, entity, relname, target, role): |
|
922 |
if role == 'subject': |
|
923 |
return '%s:%s:%s' % (entity.eid, relname, target) |
|
924 |
else: |
|
925 |
return '%s:%s:%s' % (target, relname, entity.eid) |
|
926 |
||
927 |
||
928 |
def _render_generic_relation_form(self, operations, entity, relname, role): |
|
929 |
rqlexec = self.req.execute |
|
930 |
for optype, targets in operations.items(): |
|
931 |
for target in targets: |
|
932 |
self._render_pending(optype, entity, relname, target, role) |
|
933 |
opvalue = self._build_opvalue(entity, relname, target, role) |
|
934 |
self.w(u'<a href="javascript: addPendingDelete(\'%s\', %s);">-</a> ' |
|
935 |
% (opvalue, entity.eid)) |
|
936 |
rset = rqlexec('Any X WHERE X eid %(x)s', {'x': target}, 'x') |
|
937 |
self.wview('oneline', rset) |
|
938 |
# now, unrelated ones |
|
939 |
self._render_unrelated_selection(entity, relname, role) |
|
940 |
||
941 |
def _render_pending(self, optype, entity, relname, target, role): |
|
942 |
opvalue = self._build_opvalue(entity, relname, target, role) |
|
943 |
self.w(u'<input type="hidden" name="__%s" value="%s" />' |
|
944 |
% (optype, opvalue)) |
|
945 |
if optype == 'insert': |
|
946 |
checktext = '-' |
|
947 |
else: |
|
948 |
checktext = '+' |
|
949 |
rset = self.req.execute('Any X WHERE X eid %(x)s', {'x': target}, 'x') |
|
950 |
self.w(u"""[<a href="javascript: cancelPending%s('%s:%s:%s')">%s</a>""" |
|
951 |
% (optype.capitalize(), relname, target, role, |
|
952 |
self.view('oneline', rset))) |
|
953 |
||
954 |
def _render_unrelated_selection(self, entity, relname, role): |
|
955 |
rschema = self.schema.rschema(relname) |
|
956 |
if role == 'subject': |
|
957 |
targettypes = rschema.objects(entity.e_schema) |
|
958 |
else: |
|
959 |
targettypes = rschema.subjects(entity.e_schema) |
|
960 |
self.w(u'<select onselect="addPendingInsert(this.selected.value);">') |
|
961 |
for targettype in targettypes: |
|
962 |
unrelated = entity.unrelated(relname, targettype, role) # XXX limit |
|
963 |
for rowindex, row in enumerate(unrelated): |
|
964 |
teid = row[0] |
|
965 |
opvalue = self._build_opvalue(entity, relname, teid, role) |
|
966 |
self.w(u'<option name="__insert" value="%s>%s</option>' |
|
967 |
% (opvalue, self.view('text', unrelated, row=rowindex))) |
|
968 |
self.w(u'</select>') |
|
969 |
||
970 |
||
971 |
class TextSearchResultView(EntityView): |
|
972 |
"""this view is used to display full-text search |
|
973 |
||
974 |
It tries to highlight part of data where the search word appears. |
|
975 |
||
976 |
XXX: finish me (fixed line width, fixed number of lines, CSS, etc.) |
|
977 |
""" |
|
978 |
id = 'tsearch' |
|
979 |
||
980 |
||
981 |
def cell_call(self, row, col, **kwargs): |
|
982 |
entity = self.complete_entity(row, col) |
|
983 |
self.w(entity.view('incontext')) |
|
984 |
searched = self.rset.searched_text() |
|
985 |
if searched is None: |
|
986 |
return |
|
987 |
searched = searched.lower() |
|
988 |
highlighted = '<b>%s</b>' % searched |
|
989 |
for attr in entity.e_schema.indexable_attributes(): |
|
990 |
try: |
|
991 |
value = html_escape(entity.printable_value(attr, format='text/plain').lower()) |
|
992 |
except TransformError, ex: |
|
993 |
continue |
|
994 |
except: |
|
995 |
continue |
|
996 |
if searched in value: |
|
997 |
contexts = [] |
|
998 |
for ctx in value.split(searched): |
|
999 |
if len(ctx) > 30: |
|
1000 |
contexts.append(u'...' + ctx[-30:]) |
|
1001 |
else: |
|
1002 |
contexts.append(ctx) |
|
1003 |
value = u'\n' + highlighted.join(contexts) |
|
1004 |
self.w(value.replace('\n', '<br/>')) |
|
1005 |
||
1006 |
||
1007 |
class EntityRelationView(EntityView): |
|
1008 |
accepts = () |
|
1009 |
vid = 'list' |
|
1010 |
||
1011 |
def cell_call(self, row, col): |
|
1012 |
if self.target == 'object': |
|
1013 |
role = 'subject' |
|
1014 |
else: |
|
1015 |
role = 'object' |
|
1016 |
rset = self.rset.get_entity(row, col).related(self.rtype, role) |
|
956 | 1017 |
if self.title: |
1018 |
self.w(u'<h1>%s</h1>' % self.req._(self.title).capitalize()) |
|
0 | 1019 |
self.w(u'<div class="mainInfo">') |
1020 |
self.wview(self.vid, rset, 'noresult') |
|
1021 |
self.w(u'</div>') |
|
1022 |
||
1023 |
||
1024 |
class TooltipView(OneLineView): |
|
1025 |
"""A entity view used in a tooltip""" |
|
1026 |
id = 'tooltip' |
|
1027 |
title = None # don't display in possible views |
|
1028 |
def cell_call(self, row, col): |
|
1029 |
self.wview('oneline', self.rset, row=row, col=col) |
|
1030 |
||
1031 |
try: |
|
1032 |
from cubicweb.web.views.tableview import TableView |
|
1033 |
from logilab.common.deprecation import class_moved |
|
1034 |
TableView = class_moved(TableView) |
|
1035 |
except ImportError: |
|
1036 |
pass # gae has no tableview module (yet) |