web/views/baseviews.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 23 Sep 2011 09:10:58 +0200
branchstable
changeset 7840 d6733436b0dd
parent 7836 0ada13ce2e16
child 7913 d0c6a7993cec
permissions -rw-r--r--
[web test] secondary view isn't listed anymore by possible view since it use the class_deprecated metaclass
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7815
2a164a9cf81c [exceptions] stop catching any exception in various places (closes #1942716)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7310
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: 5392
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: 5392
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: 5392
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: 5392
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: 5392
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: 5392
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: 5392
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: 5392
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: 5392
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: 5392
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: 5392
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: 5392
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: 5392
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: 5392
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: 5392
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    18
"""
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    19
HTML views
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    20
~~~~~~~~~~
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    21
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    22
Special views
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    23
`````````````
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    24
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    25
.. autoclass:: NullView
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    26
.. autoclass:: NoResultView
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    27
.. autoclass:: FinalView
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    28
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    29
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    30
Base entity views
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    31
`````````````````
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    32
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    33
.. autoclass:: InContextView
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    34
.. autoclass:: OutOfContextView
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    35
.. autoclass:: OneLineView
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    36
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    37
Those are used to display a link to an entity, whose label depends on the entity
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    38
having to be displayed in or out of context (of another entity): some entities
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    39
make sense in the context of another entity. For instance, the `Version` of a
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    40
`Project` in forge. So one may expect that 'incontext' will be called when
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    41
display a version from within the context of a project, while 'outofcontext"'
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    42
will be called in other cases. In our example, the 'incontext' view of the
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    43
version would be something like '0.1.2', while the 'outofcontext' view would
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    44
include the project name, e.g. 'baz 0.1.2' (since only a version number without
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    45
the associated project doesn't make sense if you don't know yet that you're
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    46
talking about the famous 'baz' project. |cubicweb| tries to make guess and call
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    47
'incontext'/'outofcontext' nicely. When it can't know, the 'oneline' view should
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    48
be used.
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    49
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    50
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    51
List entity views
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    52
`````````````````
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    53
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    54
.. autoclass:: ListView
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    55
.. autoclass:: SimpleListView
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    56
.. autoclass:: SameETypeListView
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    57
.. autoclass:: CSVView
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    58
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    59
Those list views can be given a 'subvid' arguments, telling the view to use of
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    60
each item in the list. When not specified, the value of the 'redirect_vid'
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    61
attribute of :class:`ListItemView` (for 'listview') or of
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    62
:class:`SimpleListView` will be used. This default to 'outofcontext' for 'list'
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    63
/ 'incontext' for 'simplelist'
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    64
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    65
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    66
Text entity views
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    67
~~~~~~~~~~~~~~~~~
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    68
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    69
Basic HTML view have some variants to be used when generating raw text, not HTML
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    70
(for notifications for instance). Also, as explained above, some of the HTML
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    71
views use those text views as a basis.
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    72
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    73
.. autoclass:: TextView
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    74
.. autoclass:: InContextTextView
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    75
.. autoclass:: OutOfContextView
5518
ceea458025b9 [web] unify list views call arguments: use subvid to specify the view to use for each item
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    76
"""
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    77
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    78
__docformat__ = "restructuredtext en"
1882
ce662160bb46 cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1760
diff changeset
    79
_ = unicode
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    80
3235
bad0ff9b0c13 fix when Interval is coming from date substraction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    81
from datetime import timedelta
5518
ceea458025b9 [web] unify list views call arguments: use subvid to specify the view to use for each item
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    82
from warnings import warn
3235
bad0ff9b0c13 fix when Interval is coming from date substraction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    83
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    84
from rql import nodes
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    85
6883
1538542a88ed [cleanup]
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6740
diff changeset
    86
from logilab.mtconverter import TransformError, xml_escape
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    87
6455
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
    88
from cubicweb import NoSelectableObject, tags
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
    89
from cubicweb.selectors import yes, empty_rset, one_etype_rset, match_kwargs
2469
b87c4d150e09 new adaptedlist view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2468
diff changeset
    90
from cubicweb.schema import display_name
756
2c3981830408 update import
sylvain.thenault@logilab.fr
parents: 742
diff changeset
    91
from cubicweb.view import EntityView, AnyRsetView, View
4023
eae23c40627a drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3890
diff changeset
    92
from cubicweb.uilib import cut, printable_value
6455
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
    93
from cubicweb.web.views import calendar
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    94
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    95
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    96
class NullView(AnyRsetView):
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    97
    """:__regid__: *null*
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    98
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
    99
    This view is the default view used when nothing needs to be rendered. It is
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   100
    always applicable and is usually used as fallback view when calling
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   101
    :meth:`_cw.view` to display nothing if the result set is empty.
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   102
    """
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   103
    __regid__ = 'null'
758
0c0dfd33a76d instantiate selectors wherever needed
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 742
diff changeset
   104
    __select__ = yes()
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   105
    def call(self, **kwargs):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   106
        pass
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   107
    cell_call = call
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   108
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   109
632
3a394a90b702 kill EmptyRsetVeiw
sylvain.thenault@logilab.fr
parents: 631
diff changeset
   110
class NoResultView(View):
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   111
    """:__regid__: *noresult*
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   112
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   113
    This view is the default view to be used when no result has been found
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   114
    (i.e. empty result set).
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   115
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   116
    It's usually used as fallback view when calling :meth:`_cw.view` to display
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   117
    "no results" if the result set is empty.
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   118
    """
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   119
    __regid__ = 'noresult'
742
99115e029dca replaced most of __selectors__ assignments with __select__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 647
diff changeset
   120
    __select__ = empty_rset()
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
   121
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   122
    def call(self, **kwargs):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   123
        self.w(u'<div class="searchMessage"><strong>%s</strong></div>\n'
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   124
               % self._cw._('No result matching query'))
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   125
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   126
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   127
class FinalView(AnyRsetView):
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   128
    """:__regid__: *final*
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   129
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   130
    Display the value of a result set cell with minimal transformations
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   131
    (i.e. you'll get a number for entities). It is applicable on any result set,
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   132
    though usually dedicated for cells containing an attribute's value.
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   133
    """
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   134
    __regid__ = 'final'
978
536c748e7b3f use non-breakable space in time display
sylvain.thenault@logilab.fr
parents: 964
diff changeset
   135
    # record generated i18n catalog messages
2996
866a2c135c33 B #345282 xhtml requires to use &#160; instead of &nbsp;
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2645
diff changeset
   136
    _('%d&#160;years')
866a2c135c33 B #345282 xhtml requires to use &#160; instead of &nbsp;
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2645
diff changeset
   137
    _('%d&#160;months')
866a2c135c33 B #345282 xhtml requires to use &#160; instead of &nbsp;
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2645
diff changeset
   138
    _('%d&#160;weeks')
866a2c135c33 B #345282 xhtml requires to use &#160; instead of &nbsp;
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2645
diff changeset
   139
    _('%d&#160;days')
866a2c135c33 B #345282 xhtml requires to use &#160; instead of &nbsp;
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2645
diff changeset
   140
    _('%d&#160;hours')
866a2c135c33 B #345282 xhtml requires to use &#160; instead of &nbsp;
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2645
diff changeset
   141
    _('%d&#160;minutes')
866a2c135c33 B #345282 xhtml requires to use &#160; instead of &nbsp;
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2645
diff changeset
   142
    _('%d&#160;seconds')
978
536c748e7b3f use non-breakable space in time display
sylvain.thenault@logilab.fr
parents: 964
diff changeset
   143
    _('%d years')
536c748e7b3f use non-breakable space in time display
sylvain.thenault@logilab.fr
parents: 964
diff changeset
   144
    _('%d months')
536c748e7b3f use non-breakable space in time display
sylvain.thenault@logilab.fr
parents: 964
diff changeset
   145
    _('%d weeks')
536c748e7b3f use non-breakable space in time display
sylvain.thenault@logilab.fr
parents: 964
diff changeset
   146
    _('%d days')
536c748e7b3f use non-breakable space in time display
sylvain.thenault@logilab.fr
parents: 964
diff changeset
   147
    _('%d hours')
536c748e7b3f use non-breakable space in time display
sylvain.thenault@logilab.fr
parents: 964
diff changeset
   148
    _('%d minutes')
536c748e7b3f use non-breakable space in time display
sylvain.thenault@logilab.fr
parents: 964
diff changeset
   149
    _('%d seconds')
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
   150
3165
0a50ebe53db7 [views] remove parameter displaytime from final view
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 2996
diff changeset
   151
    def cell_call(self, row, col, props=None, format='text/html'):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   152
        etype = self.cw_rset.description[row][col]
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   153
        value = self.cw_rset.rows[row][col]
1760
6b97d286eb5a [reledit] relation edition : cleanup a bit #343123
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1712
diff changeset
   154
4315
2f957ad8e082 [views] FinalView should display an empty string if value is None
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 4212
diff changeset
   155
        if value is None:
2f957ad8e082 [views] FinalView should display an empty string if value is None
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 4212
diff changeset
   156
            self.w(u'')
2f957ad8e082 [views] FinalView should display an empty string if value is None
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 4212
diff changeset
   157
            return
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   158
        if etype == 'String':
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   159
            entity, rtype = self.cw_rset.related_entity(row, col)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   160
            if entity is not None:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   161
                # yes !
573
9c8fd72ba6c1 try to get raw text values in rset csv view
sylvain.thenault@logilab.fr
parents: 570
diff changeset
   162
                self.w(entity.printable_value(rtype, value, format=format))
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   163
                return
4315
2f957ad8e082 [views] FinalView should display an empty string if value is None
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 4212
diff changeset
   164
        elif etype in ('Time', 'Interval'):
3235
bad0ff9b0c13 fix when Interval is coming from date substraction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
   165
            if etype == 'Interval' and isinstance(value, (int, long)):
bad0ff9b0c13 fix when Interval is coming from date substraction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
   166
                # `date - date`, unlike `datetime - datetime` gives an int
bad0ff9b0c13 fix when Interval is coming from date substraction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
   167
                # (number of days), not a timedelta
3236
df31dbf3225e add note
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3235
diff changeset
   168
                # XXX should rql be fixed to return Int instead of Interval in
df31dbf3225e add note
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3235
diff changeset
   169
                #     that case? that would be probably the proper fix but we
df31dbf3225e add note
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3235
diff changeset
   170
                #     loose information on the way...
3235
bad0ff9b0c13 fix when Interval is coming from date substraction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
   171
                value = timedelta(days=value)
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
   172
            # value is DateTimeDelta but we have no idea about what is the
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   173
            # 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
   174
            if format == 'text/html':
2996
866a2c135c33 B #345282 xhtml requires to use &#160; instead of &nbsp;
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2645
diff changeset
   175
                space = '&#160;'
978
536c748e7b3f use non-breakable space in time display
sylvain.thenault@logilab.fr
parents: 964
diff changeset
   176
            else:
536c748e7b3f use non-breakable space in time display
sylvain.thenault@logilab.fr
parents: 964
diff changeset
   177
                space = ' '
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   178
            if value.days > 730: # 2 years
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   179
                self.w(self._cw.__('%%d%syears' % space) % (value.days // 365))
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   180
            elif value.days > 60: # 2 months
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   181
                self.w(self._cw.__('%%d%smonths' % space) % (value.days // 30))
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   182
            elif value.days > 14: # 2 weeks
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   183
                self.w(self._cw.__('%%d%sweeks' % space) % (value.days // 7))
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   184
            elif value.days > 2:
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   185
                self.w(self._cw.__('%%d%sdays' % space) % int(value.days))
1712
32ab85031814 fix a bug deltatime hasn't a hours or minutes attributes
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents: 1680
diff changeset
   186
            elif value.seconds > 3600:
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   187
                self.w(self._cw.__('%%d%shours' % space) % int(value.seconds // 3600))
1712
32ab85031814 fix a bug deltatime hasn't a hours or minutes attributes
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents: 1680
diff changeset
   188
            elif value.seconds >= 120:
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   189
                self.w(self._cw.__('%%d%sminutes' % space) % int(value.seconds // 60))
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   190
            else:
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   191
                self.w(self._cw.__('%%d%sseconds' % space) % int(value.seconds))
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   192
            return
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   193
        self.wdata(printable_value(self._cw, etype, value, props))
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   194
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   195
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   196
class InContextView(EntityView):
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   197
    """:__regid__: *incontext*
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   198
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   199
    This view is used whenthe entity should be considered as displayed in its
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   200
    context. By default it produces the result of `textincontext` wrapped in a
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   201
    link leading to the primary view of the entity.
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   202
    """
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   203
    __regid__ = 'incontext'
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   204
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   205
    def cell_call(self, row, col):
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   206
        entity = self.cw_rset.get_entity(row, col)
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   207
        desc = cut(entity.dc_description(), 50)
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   208
        self.w(u'<a href="%s" title="%s">' % (
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   209
            xml_escape(entity.absolute_url()), xml_escape(desc)))
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   210
        self.w(xml_escape(self._cw.view('textincontext', self.cw_rset,
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   211
                                        row=row, col=col)))
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   212
        self.w(u'</a>')
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
   213
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   214
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   215
class OutOfContextView(EntityView):
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   216
    """:__regid__: *outofcontext*
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   217
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   218
    This view is used whenthe entity should be considered as displayed out of
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   219
    its context. By default it produces the result of `textoutofcontext` wrapped
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   220
    in a link leading to the primary view of the entity.
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   221
    """
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   222
    __regid__ = 'outofcontext'
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   223
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   224
    def cell_call(self, row, col):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   225
        entity = self.cw_rset.get_entity(row, col)
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   226
        desc = cut(entity.dc_description(), 50)
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   227
        self.w(u'<a href="%s" title="%s">' % (
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   228
            xml_escape(entity.absolute_url()), xml_escape(desc)))
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   229
        self.w(xml_escape(self._cw.view('textoutofcontext', self.cw_rset,
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   230
                                        row=row, col=col)))
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   231
        self.w(u'</a>')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   232
824
a5e6acffde30 merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents: 795
diff changeset
   233
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   234
class OneLineView(EntityView):
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   235
    """:__regid__: *oneline*
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   236
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   237
    This view is used when we can't tell if the entity should be considered as
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   238
    displayed in or out of context. By default it produces the result of the
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   239
    `text` view in a link leading to the primary view of the entity.
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   240
    """
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   241
    __regid__ = 'oneline'
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
   242
    title = _('oneline')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   243
3682
9b62c5887639 add kwargs to some base views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3264
diff changeset
   244
    def cell_call(self, row, col, **kwargs):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   245
        """the one line view for an entity: linked text view
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   246
        """
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   247
        entity = self.cw_rset.get_entity(row, col)
2312
af4d8f75c5db use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   248
        self.w(u'<a href="%s">' % xml_escape(entity.absolute_url()))
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   249
        self.w(xml_escape(self._cw.view('text', self.cw_rset, row=row, col=col)))
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   250
        self.w(u'</a>')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   251
824
a5e6acffde30 merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents: 795
diff changeset
   252
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   253
# text views ###################################################################
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   254
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   255
class TextView(EntityView):
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   256
    """:__regid__: *text*
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   257
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   258
    This is the simplest text view for an entity. By default it returns the
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   259
    result of the entity's `dc_title()` method, which is cut to fit the
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   260
    `navigation.short-line-size` property if necessary.
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   261
    """
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   262
    __regid__ = 'text'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   263
    title = _('text')
532
ce3e94cbb074 specify content type for text views
sylvain.thenault@logilab.fr
parents: 531
diff changeset
   264
    content_type = 'text/plain'
647
49bb57a9606b some selectors update + drop EntityRelationView (only used by jpl)
sylvain.thenault@logilab.fr
parents: 632
diff changeset
   265
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   266
    def call(self, **kwargs):
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   267
        """The view is called for an entire result set, by default loop other
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   268
        rows of the result set and call the same view on the particular row.
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   269
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   270
        Subclasses views that are applicable on None result sets will have to
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   271
        override this method.
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   272
        """
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   273
        rset = self.cw_rset
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   274
        if rset is None:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   275
            raise NotImplementedError, self
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   276
        for i in xrange(len(rset)):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   277
            self.wview(self.__regid__, rset, row=i, **kwargs)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   278
            if len(rset) > 1:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   279
                self.w(u"\n")
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
   280
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   281
    def cell_call(self, row, col=0, **kwargs):
3418
7b49fa7e942d [api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   282
        entity = self.cw_rset.get_entity(row, col)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   283
        self.w(cut(entity.dc_title(),
3418
7b49fa7e942d [api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   284
                   self._cw.property_value('navigation.short-line-size')))
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   285
137
7e45cf48c2f1 don't display additional owners in metadata, this is confusing
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 0
diff changeset
   286
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   287
class InContextTextView(TextView):
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   288
    """:__regid__: *textincontext*
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
   289
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   290
    Similar to the `text` view, but called when an entity is considered in
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   291
    context (see description of incontext HTML view for more information on
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   292
    this). By default it displays what's returned by the `dc_title()` method of
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   293
    the entity.
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   294
    """
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   295
    __regid__ = 'textincontext'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   296
    title = None # not listed as a possible view
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   297
    def cell_call(self, row, col):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   298
        entity = self.cw_rset.get_entity(row, col)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   299
        self.w(entity.dc_title())
824
a5e6acffde30 merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents: 795
diff changeset
   300
a5e6acffde30 merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents: 795
diff changeset
   301
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   302
class OutOfContextTextView(InContextTextView):
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   303
    """:__regid__: *textoutofcontext*
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   304
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   305
    Similar to the `text` view, but called when an entity is considered out of
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   306
    context (see description of outofcontext HTML view for more information on
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   307
    this). By default it displays what's returned by the `dc_long_title()`
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   308
    method of the entity.
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   309
    """
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   310
    __regid__ = 'textoutofcontext'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   311
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   312
    def cell_call(self, row, col):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   313
        entity = self.cw_rset.get_entity(row, col)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   314
        self.w(entity.dc_long_title())
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   315
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   316
824
a5e6acffde30 merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents: 795
diff changeset
   317
# list views ##################################################################
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   318
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   319
class ListView(EntityView):
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   320
    """:__regid__: *list*
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   321
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   322
    This view displays a list of entities by creating a HTML list (`<ul>`) and
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   323
    call the view `listitem` for each entity of the result set. The 'list' view
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   324
    will generate HTML like:
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   325
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   326
    .. sourcecode:: html
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   327
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   328
      <ul class="section">
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   329
        <li>"result of 'subvid' view for a row</li>
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   330
        ...
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   331
      </ul>
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   332
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   333
    If you wish to use a different view for each entity, either subclass and
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   334
    change the :attr:`item_vid` class attribute or specify a `subvid` argument
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   335
    when calling this view.
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   336
    """
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   337
    __regid__ = 'list'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   338
    title = _('list')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   339
    item_vid = 'listitem'
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
   340
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   341
    def call(self, klass=None, title=None, subvid=None, listid=None, **kwargs):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   342
        """display a list of entities by calling their <item_vid> view
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
   343
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   344
        :param listid: the DOM id to use for the root element
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   345
        """
2469
b87c4d150e09 new adaptedlist view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2468
diff changeset
   346
        # XXX much of the behaviour here should probably be outside this view
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   347
        if subvid is None and 'subvid' in self._cw.form:
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   348
            subvid = self._cw.form.pop('subvid') # consume it
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   349
        if listid:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   350
            listid = u' id="%s"' % listid
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   351
        else:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   352
            listid = u''
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   353
        if title:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   354
            self.w(u'<div%s class="%s"><h4>%s</h4>\n' % (listid, klass or 'section', title))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   355
            self.w(u'<ul>\n')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   356
        else:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   357
            self.w(u'<ul%s class="%s">\n' % (listid, klass or 'section'))
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   358
        for i in xrange(self.cw_rset.rowcount):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   359
            self.cell_call(row=i, col=0, vid=subvid, **kwargs)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   360
        self.w(u'</ul>\n')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   361
        if title:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   362
            self.w(u'</div>\n')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   363
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   364
    def cell_call(self, row, col=0, vid=None, **kwargs):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   365
        self.w(u'<li>')
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   366
        self.wview(self.item_vid, self.cw_rset, row=row, col=col, vid=vid, **kwargs)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   367
        self.w(u'</li>\n')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   368
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
   369
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   370
class ListItemView(EntityView):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   371
    __regid__ = 'listitem'
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
   372
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   373
    @property
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   374
    def redirect_vid(self):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   375
        if self._cw.search_state[0] == 'normal':
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   376
            return 'outofcontext'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   377
        return 'outofcontext-search'
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
   378
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   379
    def cell_call(self, row, col, vid=None, **kwargs):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   380
        if not vid:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   381
            vid = self.redirect_vid
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   382
        try:
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   383
            self.wview(vid, self.cw_rset, row=row, col=col, **kwargs)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   384
        except NoSelectableObject:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   385
            if vid == self.redirect_vid:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   386
                raise
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   387
            self.wview(self.redirect_vid, self.cw_rset, row=row, col=col, **kwargs)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   388
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   389
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   390
class SimpleListView(ListItemView):
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   391
    """:__regid__: *simplelist*
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   392
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   393
    Similar to :class:~cubicweb.web.views.baseviews.ListView but using '<div>'
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   394
    instead of '<ul>'. It rely on '<div>' behaviour to separate items. HTML will
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   395
    look like
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   396
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   397
    .. sourcecode:: html
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   398
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   399
      <div class="section">"result of 'subvid' view for a row</div>
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   400
      ...
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   401
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   402
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   403
    It relies on base :class:`~cubicweb.view.View` class implementation of the
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   404
    :meth:`call` method to insert those <div>.
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   405
    """
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   406
    __regid__ = 'simplelist'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   407
    redirect_vid = 'incontext'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   408
5518
ceea458025b9 [web] unify list views call arguments: use subvid to specify the view to use for each item
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   409
    def call(self, subvid=None, **kwargs):
ceea458025b9 [web] unify list views call arguments: use subvid to specify the view to use for each item
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   410
        """display a list of entities by calling their <item_vid> view
ceea458025b9 [web] unify list views call arguments: use subvid to specify the view to use for each item
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   411
ceea458025b9 [web] unify list views call arguments: use subvid to specify the view to use for each item
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   412
        :param listid: the DOM id to use for the root element
ceea458025b9 [web] unify list views call arguments: use subvid to specify the view to use for each item
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   413
        """
ceea458025b9 [web] unify list views call arguments: use subvid to specify the view to use for each item
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   414
        if subvid is None and 'vid' in kwargs:
ceea458025b9 [web] unify list views call arguments: use subvid to specify the view to use for each item
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   415
            warn("should give a 'subvid' argument instead of 'vid'",
ceea458025b9 [web] unify list views call arguments: use subvid to specify the view to use for each item
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   416
                 DeprecationWarning, stacklevel=2)
ceea458025b9 [web] unify list views call arguments: use subvid to specify the view to use for each item
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   417
        else:
ceea458025b9 [web] unify list views call arguments: use subvid to specify the view to use for each item
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   418
            kwargs['vid'] = subvid
ceea458025b9 [web] unify list views call arguments: use subvid to specify the view to use for each item
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   419
        return super(SimpleListView, self).call(**kwargs)
ceea458025b9 [web] unify list views call arguments: use subvid to specify the view to use for each item
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   420
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   421
4494
ccb7fce7297b AdaptedList -> SameETypeList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4482
diff changeset
   422
class SameETypeListView(EntityView):
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   423
    """:__regid__: *sameetypelist*
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   424
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   425
    This view displays a list of entities of the same type, in HTML section
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   426
    ('<div>') and call the view `sameetypelistitem` for each entity of the
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   427
    result set. It's designed to get a more adapted global list when displayed
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   428
    entities are all of the same type (for instance, display gallery if there
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   429
    are only images entities).
4494
ccb7fce7297b AdaptedList -> SameETypeList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4482
diff changeset
   430
    """
ccb7fce7297b AdaptedList -> SameETypeList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4482
diff changeset
   431
    __regid__ = 'sameetypelist'
2645
91c71276f999 F [adapted list view] fix selector
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2472
diff changeset
   432
    __select__ = EntityView.__select__ & one_etype_rset()
4494
ccb7fce7297b AdaptedList -> SameETypeList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4482
diff changeset
   433
    item_vid = 'sameetypelistitem'
2469
b87c4d150e09 new adaptedlist view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2468
diff changeset
   434
b87c4d150e09 new adaptedlist view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2468
diff changeset
   435
    @property
b87c4d150e09 new adaptedlist view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2468
diff changeset
   436
    def title(self):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   437
        etype = iter(self.cw_rset.column_types(0)).next()
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   438
        return display_name(self._cw, etype, form='plural')
2469
b87c4d150e09 new adaptedlist view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2468
diff changeset
   439
b87c4d150e09 new adaptedlist view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2468
diff changeset
   440
    def call(self, **kwargs):
b87c4d150e09 new adaptedlist view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2468
diff changeset
   441
        """display a list of entities by calling their <item_vid> view"""
5392
899d93e4dbe0 [view] better control wether same etype view should display title or not
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5222
diff changeset
   442
        showtitle = kwargs.pop('showtitle', not 'vtitle' in self._cw.form)
899d93e4dbe0 [view] better control wether same etype view should display title or not
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5222
diff changeset
   443
        if showtitle:
2469
b87c4d150e09 new adaptedlist view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2468
diff changeset
   444
            self.w(u'<h1>%s</h1>' % self.title)
4494
ccb7fce7297b AdaptedList -> SameETypeList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4482
diff changeset
   445
        super(SameETypeListView, self).call(**kwargs)
2469
b87c4d150e09 new adaptedlist view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2468
diff changeset
   446
4507
57927ad07e63 no need for a specific vid argument here
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4494
diff changeset
   447
    def cell_call(self, row, col=0, **kwargs):
57927ad07e63 no need for a specific vid argument here
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4494
diff changeset
   448
        self.wview(self.item_vid, self.cw_rset, row=row, col=col, **kwargs)
2469
b87c4d150e09 new adaptedlist view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2468
diff changeset
   449
b87c4d150e09 new adaptedlist view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2468
diff changeset
   450
4494
ccb7fce7297b AdaptedList -> SameETypeList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4482
diff changeset
   451
class SameETypeListItemView(EntityView):
ccb7fce7297b AdaptedList -> SameETypeList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4482
diff changeset
   452
    __regid__ = 'sameetypelistitem'
2469
b87c4d150e09 new adaptedlist view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2468
diff changeset
   453
4482
1f4f33535d9a we should not use inheritance there but proper view redirection, so if one adapt listitem view, he gets the same thing by default with the adapted list
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4335
diff changeset
   454
    def cell_call(self, row, col, **kwargs):
1f4f33535d9a we should not use inheritance there but proper view redirection, so if one adapt listitem view, he gets the same thing by default with the adapted list
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4335
diff changeset
   455
        self.wview('listitem', self.cw_rset, row=row, col=col, **kwargs)
2469
b87c4d150e09 new adaptedlist view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2468
diff changeset
   456
4494
ccb7fce7297b AdaptedList -> SameETypeList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4482
diff changeset
   457
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   458
class CSVView(SimpleListView):
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   459
    """:__regid__: *csv*
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   460
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   461
    This view displays each entity in a coma separated list. It is NOT related
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   462
    to the well-known text file format.
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   463
    """
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   464
    __regid__ = 'csv'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   465
    redirect_vid = 'incontext'
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
   466
5518
ceea458025b9 [web] unify list views call arguments: use subvid to specify the view to use for each item
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   467
    def call(self, subvid=None, **kwargs):
ceea458025b9 [web] unify list views call arguments: use subvid to specify the view to use for each item
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   468
        if subvid is None and 'vid' in kwargs:
6583
4e7325d6b616 [deprecation] add version info
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6455
diff changeset
   469
            warn("[3.9] should give a 'subvid' argument instead of 'vid'",
5518
ceea458025b9 [web] unify list views call arguments: use subvid to specify the view to use for each item
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   470
                 DeprecationWarning, stacklevel=2)
ceea458025b9 [web] unify list views call arguments: use subvid to specify the view to use for each item
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   471
        else:
ceea458025b9 [web] unify list views call arguments: use subvid to specify the view to use for each item
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   472
            kwargs['vid'] = subvid
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   473
        rset = self.cw_rset
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   474
        for i in xrange(len(rset)):
5518
ceea458025b9 [web] unify list views call arguments: use subvid to specify the view to use for each item
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
   475
            self.cell_call(i, 0, **kwargs)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   476
            if i < rset.rowcount-1:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   477
                self.w(u", ")
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   478
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   479
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   480
# XXX to be documented views ###################################################
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   481
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   482
class MetaDataView(EntityView):
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   483
    """paragraph view of some metadata"""
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   484
    __regid__ = 'metadata'
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   485
    show_eid = True
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   486
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   487
    def cell_call(self, row, col):
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   488
        _ = self._cw._
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   489
        entity = self.cw_rset.get_entity(row, col)
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   490
        self.w(u'<div>')
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   491
        if self.show_eid:
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   492
            self.w(u'%s #%s - ' % (entity.dc_type(), entity.eid))
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   493
        if entity.modification_date != entity.creation_date:
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   494
            self.w(u'<span>%s</span> ' % _('latest update on'))
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   495
            self.w(u'<span class="value">%s</span>, '
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   496
                   % self._cw.format_date(entity.modification_date))
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   497
        # entities from external source may not have a creation date (eg ldap)
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   498
        if entity.creation_date:
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   499
            self.w(u'<span>%s</span> ' % _('created on'))
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   500
            self.w(u'<span class="value">%s</span>'
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   501
                   % self._cw.format_date(entity.creation_date))
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   502
        if entity.creator:
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   503
            if entity.creation_date:
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   504
                self.w(u' <span>%s</span> ' % _('by'))
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   505
            else:
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   506
                self.w(u' <span>%s</span> ' % _('created_by'))
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   507
            self.w(u'<span class="value">%s</span>' % entity.creator.name())
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   508
        meta = entity.cw_metainformation()
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   509
        if meta['source']['uri'] != 'system':
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   510
            self.w(u' (<span>%s</span>' % _('cw_source'))
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   511
            self.w(u' <span class="value">%s</span>)' % meta['source']['uri'])
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   512
        self.w(u'</div>')
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   513
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   514
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   515
class TreeItemView(ListItemView):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   516
    __regid__ = 'treeitem'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   517
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   518
    def cell_call(self, row, col):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   519
        self.wview('incontext', self.cw_rset, row=row, col=col)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   520
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   521
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   522
class TextSearchResultView(EntityView):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   523
    """this view is used to display full-text search
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   524
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   525
    It tries to highlight part of data where the search word appears.
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   526
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   527
    XXX: finish me (fixed line width, fixed number of lines, CSS, etc.)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   528
    """
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   529
    __regid__ = 'tsearch'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   530
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   531
    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: 3418
diff changeset
   532
        entity = self.cw_rset.complete_entity(row, col)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   533
        self.w(entity.view('incontext'))
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   534
        searched = self.cw_rset.searched_text()
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   535
        if searched is None:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   536
            return
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   537
        searched = searched.lower()
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   538
        highlighted = '<b>%s</b>' % searched
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   539
        for attr in entity.e_schema.indexable_attributes():
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   540
            try:
1680
39860636e184 use xml_escape
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents: 1653
diff changeset
   541
                value = xml_escape(entity.printable_value(attr, format='text/plain').lower())
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   542
            except TransformError, ex:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   543
                continue
7815
2a164a9cf81c [exceptions] stop catching any exception in various places (closes #1942716)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7310
diff changeset
   544
            except Exception:
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   545
                continue
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   546
            if searched in value:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   547
                contexts = []
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   548
                for ctx in value.split(searched):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   549
                    if len(ctx) > 30:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   550
                        contexts.append(u'...' + ctx[-30:])
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   551
                    else:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   552
                        contexts.append(ctx)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   553
                value = u'\n' + highlighted.join(contexts)
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
   554
                self.w(value.replace('\n', '<br/>'))
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   555
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   556
824
a5e6acffde30 merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents: 795
diff changeset
   557
class TooltipView(EntityView):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   558
    """A entity view used in a tooltip"""
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   559
    __regid__ = 'tooltip'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   560
    def cell_call(self, row, col):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3418
diff changeset
   561
        self.wview('oneline', self.cw_rset, row=row, col=col)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   562
824
a5e6acffde30 merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents: 795
diff changeset
   563
6455
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   564
class GroupByView(EntityView):
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   565
    """grouped view of a result set. The `group_key` method return the group
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   566
    key of an entities (a string or tuple of string).
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   567
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   568
    For each group, display a link to entities of this group by generating url
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   569
    like <basepath>/<key> or <basepath>/<key item 1>/<key item 2>.
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   570
    """
7835
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7815
diff changeset
   571
    __abstract__ = True
6455
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   572
    __select__ = EntityView.__select__ & match_kwargs('basepath')
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   573
    entity_attribute = None
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   574
    reversed = False
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   575
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   576
    def index_url(self, basepath, key, **kwargs):
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   577
        if isinstance(key, (list, tuple)):
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   578
            key = '/'.join(key)
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   579
        return self._cw.build_url('%s/%s' % (basepath, key),
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   580
                                  **kwargs)
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   581
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   582
    def index_link(self, basepath, key, items):
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   583
        url = self.index_url(basepath, key)
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   584
        if isinstance(key, (list, tuple)):
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   585
            key = ' '.join(key)
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   586
        return tags.a(key, href=url)
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   587
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   588
    def group_key(self, entity, **kwargs):
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   589
        value = getattr(entity, self.entity_attribute)
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   590
        if callable(value):
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   591
            value = value()
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   592
        return value
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   593
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   594
    def call(self, basepath, maxentries=None, **kwargs):
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   595
        index = {}
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   596
        for entity in self.cw_rset.entities():
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   597
            index.setdefault(self.group_key(entity, **kwargs), []).append(entity)
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   598
        displayed = sorted(index)
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   599
        if self.reversed:
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   600
            displayed = reversed(displayed)
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   601
        if maxentries is None:
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   602
            needmore = False
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   603
        else:
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   604
            needmore = len(index) > maxentries
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   605
            displayed = tuple(displayed)[:maxentries]
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   606
        w = self.w
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   607
        w(u'<ul class="boxListing">')
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   608
        for key in displayed:
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   609
            w(u'<li>%s</li>\n' %
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   610
              self.index_link(basepath, key, index[key]))
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   611
        if needmore:
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   612
            url = self._cw.build_url('view', vid=self.__regid__,
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   613
                                     rql=self.cw_rset.printable_rql())
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   614
            w( u'<li>%s</li>\n' % tags.a(u'[%s]' % self._cw._('see more'),
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   615
                                         href=url))
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   616
        w(u'</ul>\n')
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   617
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   618
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   619
class ArchiveView(GroupByView):
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   620
    """archive view of a result set. Links to months are built using a basepath
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   621
    parameters, eg using url like <basepath>/<year>/<month>
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   622
    """
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   623
    __regid__ = 'cw.archive.by_date'
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   624
    entity_attribute = 'creation_date'
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   625
    reversed = True
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   626
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   627
    def group_key(self, entity, **kwargs):
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   628
        value = super(ArchiveView, self).group_key(entity, **kwargs)
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   629
        return '%04d' % value.year, '%02d' % value.month
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   630
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   631
    def index_link(self, basepath, key, items):
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   632
        """represent a single month entry"""
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   633
        year, month = key
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   634
        label = u'%s %s [%s]' % (self._cw._(calendar.MONTHNAMES[int(month)-1]),
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   635
                                 year, len(items))
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   636
        etypes = set(entity.__regid__ for entity in items)
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   637
        vtitle = '%s %s' % (', '.join(display_name(self._cw, etype, 'plural')
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   638
                                      for etype in etypes),
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   639
                            label)
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   640
        title = self._cw._('archive for %(month)s/%(year)s') % {
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   641
            'month': month, 'year': year}
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   642
        url = self.index_url(basepath, key, vtitle=vtitle)
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   643
        return tags.a(label, href=url, title=title)
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   644
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   645
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   646
class AuthorView(GroupByView):
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   647
    """author view of a result set. Links to month are built using a basepath
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   648
    parameters, eg using url like <basepath>/<author>
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   649
    """
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   650
    __regid__ = 'cw.archive.by_author'
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   651
    entity_attribute = 'creator'
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   652
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   653
    def group_key(self, entity, **kwargs):
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   654
        value = super(AuthorView, self).group_key(entity, **kwargs)
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   655
        if value:
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   656
            return value.login
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   657
        return value
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   658
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   659
    def index_link(self, basepath, key, items):
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   660
        label = u'%s [%s]' % (key, len(items))
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   661
        etypes = set(entity.__regid__ for entity in items)
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   662
        vtitle = self._cw._('%(etype)s by %(author)s') % {
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   663
            'etype': ', '.join(display_name(self._cw, etype, 'plural')
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   664
                               for etype in etypes),
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   665
            'author': label}
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   666
        url = self.index_url(basepath, key, vtitle=vtitle)
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   667
        title = self._cw._('archive for %(author)s') % {'author': key}
3282742dd4c6 [baseviews] new cw.archive.[by_author|by_date] views, extracted from blog
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5518
diff changeset
   668
        return tags.a(label, href=url, title=title)
7836
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   669
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   670
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   671
# bw compat ####################################################################
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   672
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   673
from logilab.common.deprecation import class_moved, class_deprecated
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   674
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   675
from cubicweb.web.views import boxes, xmlrss, primary, tableview
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   676
PrimaryView = class_moved(primary.PrimaryView)
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   677
SideBoxView = class_moved(boxes.SideBoxView)
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   678
XmlView = class_moved(xmlrss.XMLView)
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   679
XmlItemView = class_moved(xmlrss.XMLItemView)
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   680
XmlRsetView = class_moved(xmlrss.XMLRsetView)
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   681
RssView = class_moved(xmlrss.RSSView)
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   682
RssItemView = class_moved(xmlrss.RSSItemView)
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   683
TableView = class_moved(tableview.TableView)
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   684
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   685
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   686
class SecondaryView(EntityView):
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   687
    __metaclass__ = class_deprecated
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   688
    __deprecation_warning__ = '[3.9] the secondary view is deprecated, use one of oneline/incontext/outofcontext'
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   689
    __regid__ = 'secondary'
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   690
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   691
    def cell_call(self, row, col, **kwargs):
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   692
        entity = self.cw_rset.get_entity(row, col)
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   693
        self.w(u'&#160;')
0ada13ce2e16 [doc] get back baseviews documentation into the code, enhance it and reorganize the module accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7835
diff changeset
   694
        self.wview('oneline', self.cw_rset, row=row, col=col)