author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Wed, 09 May 2012 17:15:44 +0200 | |
changeset 8394 | b8b23af60019 |
parent 8190 | 2a3c1b787688 |
child 9256 | 697a8181ba30 |
permissions | -rw-r--r-- |
7101
de388d0b727e
[components] add **kwargs to render method of header components to make them usable as regular components (eg in other places than the header
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6920
diff
changeset
|
1 |
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5291
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5291
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5291
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5291
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5291
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5291
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5291
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5291
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5291
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5291
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5291
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5291
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5291
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5291
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5291
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
5722
61d6a4caa963
[iprogress] move adapter to entities.adapters
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5569
diff
changeset
|
18 |
"""breadcrumbs components definition for CubicWeb web client""" |
0 | 19 |
|
20 |
__docformat__ = "restructuredtext en" |
|
1882 | 21 |
_ = unicode |
0 | 22 |
|
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
23 |
from warnings import warn |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
24 |
|
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
25 |
from logilab.mtconverter import xml_escape |
0 | 26 |
|
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
27 |
#from cubicweb.interfaces import IBreadCrumbs |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
28 |
from cubicweb import tags, uilib |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
29 |
from cubicweb.entity import Entity |
8190
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7979
diff
changeset
|
30 |
from cubicweb.predicates import (is_instance, one_line_rset, adaptable, |
7841
287813c487b7
[breadcrumbs] keep proper breadcrumbs when creating an entity linked to another by inspecting __linkto (closes #1947476)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7511
diff
changeset
|
31 |
one_etype_rset, multi_lines_rset, any_rset, |
287813c487b7
[breadcrumbs] keep proper breadcrumbs when creating an entity linked to another by inspecting __linkto (closes #1947476)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7511
diff
changeset
|
32 |
match_form_params) |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
33 |
from cubicweb.view import EntityView, EntityAdapter |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
34 |
from cubicweb.web.views import basecomponents |
713
5adb6d8e5fa7
update imports of "cubicweb.common.entity" and use the new module path "cubicweb.entity"
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
692
diff
changeset
|
35 |
# don't use AnyEntity since this may cause bug with isinstance() due to reloading |
0 | 36 |
|
37 |
||
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
38 |
# ease bw compat |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
39 |
def ibreadcrumb_adapter(entity): |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
40 |
if hasattr(entity, 'breadcrumbs'): |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
41 |
warn('[3.9] breadcrumbs() method is deprecated, define a custom ' |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
42 |
'IBreadCrumbsAdapter for %s instead' % entity.__class__, |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
43 |
DeprecationWarning) |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
44 |
return entity |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
45 |
return entity.cw_adapt_to('IBreadCrumbs') |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
46 |
|
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
47 |
|
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
48 |
class IBreadCrumbsAdapter(EntityAdapter): |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
49 |
"""adapters for entities which can be"located" on some path to display in |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
50 |
the web ui |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
51 |
""" |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
52 |
__regid__ = 'IBreadCrumbs' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5722
diff
changeset
|
53 |
__select__ = is_instance('Any', accept_none=False) |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
54 |
|
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
55 |
def parent_entity(self): |
6920
c41336a682ed
[ibreadcrumb] fix breadcrumb adapter backward compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6698
diff
changeset
|
56 |
if hasattr(self.entity, 'parent') and callable(self.entity.parent): |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
57 |
warn('[3.9] parent() method is deprecated, define a ' |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
58 |
'custom IBreadCrumbsAdapter/ITreeAdapter for %s instead' |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
59 |
% self.entity.__class__, DeprecationWarning) |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
60 |
return self.entity.parent() |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
61 |
itree = self.entity.cw_adapt_to('ITree') |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
62 |
if itree is not None: |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
63 |
return itree.parent() |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
64 |
return None |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
65 |
|
6430
dc4398d094be
[breadcrumb] infinite loop safety belt, bw compatible by hi-jacking 'recurs' argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6428
diff
changeset
|
66 |
def breadcrumbs(self, view=None, recurs=None): |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
67 |
"""return a list containing some: |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
68 |
|
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
69 |
* tuple (url, label) |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
70 |
* entity |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
71 |
* simple label string |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
72 |
|
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
73 |
defining path from a root to the current view |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
74 |
|
6430
dc4398d094be
[breadcrumb] infinite loop safety belt, bw compatible by hi-jacking 'recurs' argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6428
diff
changeset
|
75 |
the main view is given as argument so breadcrumbs may vary according to |
dc4398d094be
[breadcrumb] infinite loop safety belt, bw compatible by hi-jacking 'recurs' argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6428
diff
changeset
|
76 |
displayed view (may be None). When recursing on a parent entity, the |
dc4398d094be
[breadcrumb] infinite loop safety belt, bw compatible by hi-jacking 'recurs' argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6428
diff
changeset
|
77 |
`recurs` argument should be a set of already traversed nodes (infinite |
dc4398d094be
[breadcrumb] infinite loop safety belt, bw compatible by hi-jacking 'recurs' argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6428
diff
changeset
|
78 |
loop safety belt). |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
79 |
""" |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
80 |
parent = self.parent_entity() |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
81 |
if parent is not None: |
6451
f64899fa0b5c
fix pre 3.10 bw compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6431
diff
changeset
|
82 |
if recurs is True: |
f64899fa0b5c
fix pre 3.10 bw compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6431
diff
changeset
|
83 |
_recurs = set() |
f64899fa0b5c
fix pre 3.10 bw compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6431
diff
changeset
|
84 |
warn('[3.10] recurs argument should be a set() or None', |
f64899fa0b5c
fix pre 3.10 bw compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6431
diff
changeset
|
85 |
DeprecationWarning, stacklevel=2) |
f64899fa0b5c
fix pre 3.10 bw compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6431
diff
changeset
|
86 |
elif recurs: |
6430
dc4398d094be
[breadcrumb] infinite loop safety belt, bw compatible by hi-jacking 'recurs' argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6428
diff
changeset
|
87 |
_recurs = recurs |
dc4398d094be
[breadcrumb] infinite loop safety belt, bw compatible by hi-jacking 'recurs' argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6428
diff
changeset
|
88 |
else: |
6431 | 89 |
if recurs is False: |
6430
dc4398d094be
[breadcrumb] infinite loop safety belt, bw compatible by hi-jacking 'recurs' argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6428
diff
changeset
|
90 |
warn('[3.10] recurs argument should be a set() or None', |
dc4398d094be
[breadcrumb] infinite loop safety belt, bw compatible by hi-jacking 'recurs' argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6428
diff
changeset
|
91 |
DeprecationWarning, stacklevel=2) |
dc4398d094be
[breadcrumb] infinite loop safety belt, bw compatible by hi-jacking 'recurs' argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6428
diff
changeset
|
92 |
_recurs = set() |
dc4398d094be
[breadcrumb] infinite loop safety belt, bw compatible by hi-jacking 'recurs' argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6428
diff
changeset
|
93 |
if _recurs and parent.eid in _recurs: |
dc4398d094be
[breadcrumb] infinite loop safety belt, bw compatible by hi-jacking 'recurs' argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6428
diff
changeset
|
94 |
self.error('cycle in breadcrumbs for entity %s' % self.entity) |
dc4398d094be
[breadcrumb] infinite loop safety belt, bw compatible by hi-jacking 'recurs' argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6428
diff
changeset
|
95 |
return [] |
dc4398d094be
[breadcrumb] infinite loop safety belt, bw compatible by hi-jacking 'recurs' argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6428
diff
changeset
|
96 |
_recurs.add(parent.eid) |
5569
cb14af012a96
[adapters] refactoring fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5556
diff
changeset
|
97 |
adapter = ibreadcrumb_adapter(parent) |
6430
dc4398d094be
[breadcrumb] infinite loop safety belt, bw compatible by hi-jacking 'recurs' argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6428
diff
changeset
|
98 |
path = adapter.breadcrumbs(view, _recurs) + [self.entity] |
5569
cb14af012a96
[adapters] refactoring fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5556
diff
changeset
|
99 |
else: |
cb14af012a96
[adapters] refactoring fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5556
diff
changeset
|
100 |
path = [self.entity] |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
101 |
if not recurs: |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
102 |
if view is None: |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
103 |
if 'vtitle' in self._cw.form: |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
104 |
# embeding for instance |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
105 |
path.append( self._cw.form['vtitle'] ) |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
106 |
elif view.__regid__ != 'primary' and hasattr(view, 'title'): |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
107 |
path.append( self._cw._(view.title) ) |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
108 |
return path |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
109 |
|
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
110 |
|
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
111 |
class BreadCrumbEntityVComponent(basecomponents.HeaderComponent): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3185
diff
changeset
|
112 |
__regid__ = 'breadcrumbs' |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
113 |
__select__ = (basecomponents.HeaderComponent.__select__ |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
114 |
& one_line_rset() & adaptable('IBreadCrumbs')) |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
115 |
order = basecomponents.ApplicationName.order + 1 |
6698
b353e868b74f
[basetemplates] breadcrumbs component context sticks to ApplicationName
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6451
diff
changeset
|
116 |
context = basecomponents.ApplicationName.context |
2996
866a2c135c33
B #345282 xhtml requires to use   instead of
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2312
diff
changeset
|
117 |
separator = u' > ' |
3862
4908c7156eab
[breadcrumbs] make it easier to redefine html structure of breadcrumbs component
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3523
diff
changeset
|
118 |
link_template = u'<a href="%s">%s</a>' |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
119 |
first_separator = True |
0 | 120 |
|
7101
de388d0b727e
[components] add **kwargs to render method of header components to make them usable as regular components (eg in other places than the header
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6920
diff
changeset
|
121 |
# XXX support kwargs for compat with other components which gets the view as |
de388d0b727e
[components] add **kwargs to render method of header components to make them usable as regular components (eg in other places than the header
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6920
diff
changeset
|
122 |
# argument |
de388d0b727e
[components] add **kwargs to render method of header components to make them usable as regular components (eg in other places than the header
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6920
diff
changeset
|
123 |
def render(self, w, **kwargs): |
7841
287813c487b7
[breadcrumbs] keep proper breadcrumbs when creating an entity linked to another by inspecting __linkto (closes #1947476)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7511
diff
changeset
|
124 |
try: |
287813c487b7
[breadcrumbs] keep proper breadcrumbs when creating an entity linked to another by inspecting __linkto (closes #1947476)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7511
diff
changeset
|
125 |
entity = self.cw_extra_kwargs['entity'] |
287813c487b7
[breadcrumbs] keep proper breadcrumbs when creating an entity linked to another by inspecting __linkto (closes #1947476)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7511
diff
changeset
|
126 |
except KeyError: |
287813c487b7
[breadcrumbs] keep proper breadcrumbs when creating an entity linked to another by inspecting __linkto (closes #1947476)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7511
diff
changeset
|
127 |
entity = self.cw_rset.get_entity(0, 0) |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
128 |
adapter = ibreadcrumb_adapter(entity) |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
129 |
view = self.cw_extra_kwargs.get('view') |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
130 |
path = adapter.breadcrumbs(view) |
0 | 131 |
if path: |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
132 |
self.open_breadcrumbs(w) |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
133 |
if self.first_separator: |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
134 |
w(self.separator) |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
135 |
self.render_breadcrumbs(w, entity, path) |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
136 |
self.close_breadcrumbs(w) |
3862
4908c7156eab
[breadcrumbs] make it easier to redefine html structure of breadcrumbs component
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3523
diff
changeset
|
137 |
|
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
138 |
def open_breadcrumbs(self, w): |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
139 |
w(u'<span id="breadcrumbs" class="pathbar">') |
3862
4908c7156eab
[breadcrumbs] make it easier to redefine html structure of breadcrumbs component
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3523
diff
changeset
|
140 |
|
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
141 |
def close_breadcrumbs(self, w): |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
142 |
w(u'</span>') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
984
diff
changeset
|
143 |
|
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
144 |
def render_breadcrumbs(self, w, contextentity, path): |
3007
a15e982aa9a3
[breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2996
diff
changeset
|
145 |
root = path.pop(0) |
a15e982aa9a3
[breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2996
diff
changeset
|
146 |
if isinstance(root, Entity): |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
147 |
w(self.link_template % (self._cw.build_url(root.__regid__), |
3862
4908c7156eab
[breadcrumbs] make it easier to redefine html structure of breadcrumbs component
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3523
diff
changeset
|
148 |
root.dc_type('plural'))) |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
149 |
w(self.separator) |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
150 |
self.wpath_part(w, root, contextentity, not path) |
3007
a15e982aa9a3
[breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2996
diff
changeset
|
151 |
for i, parent in enumerate(path): |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
152 |
w(self.separator) |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
153 |
w(u"\n") |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
154 |
self.wpath_part(w, parent, contextentity, i == len(path) - 1) |
3007
a15e982aa9a3
[breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2996
diff
changeset
|
155 |
|
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
156 |
def wpath_part(self, w, part, contextentity, last=False): # XXX deprecates last argument? |
0 | 157 |
if isinstance(part, Entity): |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
158 |
w(part.view('breadcrumbs')) |
0 | 159 |
elif isinstance(part, tuple): |
160 |
url, title = part |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
161 |
textsize = self._cw.property_value('navigation.short-line-size') |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
162 |
w(self.link_template % ( |
3179
0684544f6d0d
from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3030
diff
changeset
|
163 |
xml_escape(url), xml_escape(uilib.cut(title, textsize)))) |
0 | 164 |
else: |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
165 |
textsize = self._cw.property_value('navigation.short-line-size') |
7976
48e1f7992507
[ibreadcrumbs] missing xml_escape on latest path part (usually view's title). Closes #2037506
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7511
diff
changeset
|
166 |
w(xml_escape(uilib.cut(unicode(part), textsize))) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
984
diff
changeset
|
167 |
|
0 | 168 |
|
3007
a15e982aa9a3
[breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2996
diff
changeset
|
169 |
class BreadCrumbETypeVComponent(BreadCrumbEntityVComponent): |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
170 |
__select__ = (basecomponents.HeaderComponent.__select__ |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
171 |
& multi_lines_rset() & one_etype_rset() |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
172 |
& adaptable('IBreadCrumbs')) |
3007
a15e982aa9a3
[breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2996
diff
changeset
|
173 |
|
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
174 |
def render_breadcrumbs(self, w, contextentity, path): |
3007
a15e982aa9a3
[breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2996
diff
changeset
|
175 |
# XXX hack: only display etype name or first non entity path part |
a15e982aa9a3
[breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2996
diff
changeset
|
176 |
root = path.pop(0) |
a15e982aa9a3
[breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2996
diff
changeset
|
177 |
if isinstance(root, Entity): |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
178 |
w(u'<a href="%s">%s</a>' % (self._cw.build_url(root.__regid__), |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
179 |
root.dc_type('plural'))) |
3007
a15e982aa9a3
[breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2996
diff
changeset
|
180 |
else: |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
181 |
self.wpath_part(w, root, contextentity, not path) |
3007
a15e982aa9a3
[breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2996
diff
changeset
|
182 |
|
a15e982aa9a3
[breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2996
diff
changeset
|
183 |
|
a15e982aa9a3
[breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2996
diff
changeset
|
184 |
class BreadCrumbAnyRSetVComponent(BreadCrumbEntityVComponent): |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
185 |
__select__ = basecomponents.HeaderComponent.__select__ & any_rset() |
3007
a15e982aa9a3
[breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2996
diff
changeset
|
186 |
|
7101
de388d0b727e
[components] add **kwargs to render method of header components to make them usable as regular components (eg in other places than the header
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6920
diff
changeset
|
187 |
# XXX support kwargs for compat with other components which gets the view as |
de388d0b727e
[components] add **kwargs to render method of header components to make them usable as regular components (eg in other places than the header
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6920
diff
changeset
|
188 |
# argument |
de388d0b727e
[components] add **kwargs to render method of header components to make them usable as regular components (eg in other places than the header
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6920
diff
changeset
|
189 |
def render(self, w, **kwargs): |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
190 |
w(u'<span id="breadcrumbs" class="pathbar">') |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
191 |
if self.first_separator: |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
192 |
w(self.separator) |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
193 |
w(self._cw._('search')) |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6141
diff
changeset
|
194 |
w(u'</span>') |
0 | 195 |
|
196 |
||
7841
287813c487b7
[breadcrumbs] keep proper breadcrumbs when creating an entity linked to another by inspecting __linkto (closes #1947476)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7511
diff
changeset
|
197 |
class BreadCrumbLinkToVComponent(BreadCrumbEntityVComponent): |
287813c487b7
[breadcrumbs] keep proper breadcrumbs when creating an entity linked to another by inspecting __linkto (closes #1947476)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7511
diff
changeset
|
198 |
__select__ = basecomponents.HeaderComponent.__select__ & match_form_params('__linkto') |
287813c487b7
[breadcrumbs] keep proper breadcrumbs when creating an entity linked to another by inspecting __linkto (closes #1947476)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7511
diff
changeset
|
199 |
|
287813c487b7
[breadcrumbs] keep proper breadcrumbs when creating an entity linked to another by inspecting __linkto (closes #1947476)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7511
diff
changeset
|
200 |
def render(self, w, **kwargs): |
287813c487b7
[breadcrumbs] keep proper breadcrumbs when creating an entity linked to another by inspecting __linkto (closes #1947476)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7511
diff
changeset
|
201 |
eid = self._cw.list_form_param('__linkto')[0].split(':')[1] |
287813c487b7
[breadcrumbs] keep proper breadcrumbs when creating an entity linked to another by inspecting __linkto (closes #1947476)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7511
diff
changeset
|
202 |
entity = self._cw.entity_from_eid(eid) |
287813c487b7
[breadcrumbs] keep proper breadcrumbs when creating an entity linked to another by inspecting __linkto (closes #1947476)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7511
diff
changeset
|
203 |
ecmp = self._cw.vreg[self.__registry__].select( |
287813c487b7
[breadcrumbs] keep proper breadcrumbs when creating an entity linked to another by inspecting __linkto (closes #1947476)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7511
diff
changeset
|
204 |
self.__regid__, self._cw, entity=entity, **kwargs) |
287813c487b7
[breadcrumbs] keep proper breadcrumbs when creating an entity linked to another by inspecting __linkto (closes #1947476)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7511
diff
changeset
|
205 |
ecmp.render(w, **kwargs) |
287813c487b7
[breadcrumbs] keep proper breadcrumbs when creating an entity linked to another by inspecting __linkto (closes #1947476)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7511
diff
changeset
|
206 |
|
287813c487b7
[breadcrumbs] keep proper breadcrumbs when creating an entity linked to another by inspecting __linkto (closes #1947476)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7511
diff
changeset
|
207 |
|
0 | 208 |
class BreadCrumbView(EntityView): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3185
diff
changeset
|
209 |
__regid__ = 'breadcrumbs' |
0 | 210 |
|
4802
fa2297d6542a
[views/breadcrumbs] fix bad signature
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
4320
diff
changeset
|
211 |
def cell_call(self, row, col, **kwargs): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
212 |
entity = self.cw_rset.get_entity(row, col) |
7511
dfe6c25c6371
[breadcrumbs] closes #1717489: Double escaping in breadcrumbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7103
diff
changeset
|
213 |
desc = uilib.cut(entity.dc_description(), 50) |
7103 | 214 |
# NOTE remember camember: tags.a autoescapes |
3179
0684544f6d0d
from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3030
diff
changeset
|
215 |
self.w(tags.a(entity.view('breadcrumbtext'), |
0684544f6d0d
from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3030
diff
changeset
|
216 |
href=entity.absolute_url(), title=desc)) |
0684544f6d0d
from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3030
diff
changeset
|
217 |
|
0684544f6d0d
from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3030
diff
changeset
|
218 |
|
0684544f6d0d
from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3030
diff
changeset
|
219 |
class BreadCrumbTextView(EntityView): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3185
diff
changeset
|
220 |
__regid__ = 'breadcrumbtext' |
3179
0684544f6d0d
from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3030
diff
changeset
|
221 |
|
4802
fa2297d6542a
[views/breadcrumbs] fix bad signature
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
4320
diff
changeset
|
222 |
def cell_call(self, row, col, **kwargs): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
223 |
entity = self.cw_rset.get_entity(row, col) |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
224 |
textsize = self._cw.property_value('navigation.short-line-size') |
3179
0684544f6d0d
from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3030
diff
changeset
|
225 |
self.w(uilib.cut(entity.dc_title(), textsize)) |