cubicweb/web/views/pyviews.py
author Philippe Pepiot <philippe.pepiot@logilab.fr>
Thu, 19 Jan 2017 15:27:39 +0100
changeset 11899 bf6106b91633
parent 11767 432f87a63057
child 12567 26744ad37953
permissions -rw-r--r--
[schema] load schema from modules names instead of directories Introspect cubicweb, cubes and apphome using pkgutil to generate the full list of modules names for loading the schema. Keep historical behavior and check if source .py file exists if a module is found using python bytecode file (.pyc and .pyo) Loading schema from apphome require apphome to be present in sys.path and that "schema" module resolve to a file located in apphome. Update migraction tests to explicitely update sys.path when loading schema from different apps, use a contextmanager for this so it's more readable. Require updated logilab-common and yams
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7903
ac658ab4c7b7 [pyviews] new colheaders and cssclass arguments on pyvaltable (closes #1979718)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6802
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: 4863
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: 4863
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: 4863
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: 4863
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: 4863
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: 4863
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: 4863
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: 4863
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: 4863
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: 4863
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: 4863
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: 4863
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: 4863
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: 4863
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: 4863
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
6088
28f49a4fe702 [doc] docstring more explicit for pyviews
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5424
diff changeset
    18
"""Basic views for python values (eg without any result set)
1987
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    19
"""
11767
432f87a63057 flake8 and all
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11057
diff changeset
    20
1987
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    21
10717
46f934bebd85 [py3k] unicode → six.text_type
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10609
diff changeset
    22
from six import text_type
10609
e2d8e81bfe68 [py3k] import range using six.moves
Rémi Cardona <remi.cardona@logilab.fr>
parents: 8190
diff changeset
    23
from six.moves import range
e2d8e81bfe68 [py3k] import range using six.moves
Rémi Cardona <remi.cardona@logilab.fr>
parents: 8190
diff changeset
    24
1987
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    25
from cubicweb.view import View
8190
2a3c1b787688 [vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7992
diff changeset
    26
from cubicweb.predicates import match_kwargs
7992
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    27
from cubicweb.web.views import tableview
1987
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    28
6088
28f49a4fe702 [doc] docstring more explicit for pyviews
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 5424
diff changeset
    29
7992
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    30
class PyValTableColRenderer(tableview.AbstractColumnRenderer):
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    31
    """Default column renderer for :class:`PyValTableView`."""
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    32
    def bind(self, view, colid):
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    33
        super(PyValTableColRenderer, self).bind(view, colid)
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    34
        self.header = view.headers[colid] if view.headers else None
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    35
        self.data = view.pyvalue
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    36
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    37
    def render_header(self, w):
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    38
        if self.header:
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    39
            w(self._cw._(self.header))
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    40
        else:
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    41
            w(self.empty_cell_content)
6802
ff9059e144f9 [pyviews] document the fact that content is not xml-escaped (closes #1382038)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6088
diff changeset
    42
7992
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    43
    def render_cell(self, w, rownum):
10717
46f934bebd85 [py3k] unicode → six.text_type
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10609
diff changeset
    44
        w(text_type(self.data[rownum][self.colid]))
7992
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    45
7903
ac658ab4c7b7 [pyviews] new colheaders and cssclass arguments on pyvaltable (closes #1979718)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6802
diff changeset
    46
7992
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    47
class PyValTableView(tableview.TableMixIn, View):
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    48
    """This table view is designed to be used a list of list of unicode values
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    49
    given as a mandatory `pyvalue` argument. Take care, content is NOT
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    50
    xml-escaped.
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    51
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    52
    It's configured through the following selection arguments.
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    53
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    54
    If `headers` is specified, it is expected to be a list of headers to be
7903
ac658ab4c7b7 [pyviews] new colheaders and cssclass arguments on pyvaltable (closes #1979718)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6802
diff changeset
    55
    inserted as first row (in <thead>).
ac658ab4c7b7 [pyviews] new colheaders and cssclass arguments on pyvaltable (closes #1979718)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6802
diff changeset
    56
7992
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    57
    `header_column_idx` may be used to specify a column index or a set of column
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    58
    indiced where values should be inserted inside <th> tag instead of <td>.
7903
ac658ab4c7b7 [pyviews] new colheaders and cssclass arguments on pyvaltable (closes #1979718)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6802
diff changeset
    59
ac658ab4c7b7 [pyviews] new colheaders and cssclass arguments on pyvaltable (closes #1979718)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6802
diff changeset
    60
    `cssclass` is the CSS class used on the <table> tag, and default to
ac658ab4c7b7 [pyviews] new colheaders and cssclass arguments on pyvaltable (closes #1979718)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6802
diff changeset
    61
    'listing' (so that the table will look similar to those generated by the
ac658ab4c7b7 [pyviews] new colheaders and cssclass arguments on pyvaltable (closes #1979718)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6802
diff changeset
    62
    table view).
6802
ff9059e144f9 [pyviews] document the fact that content is not xml-escaped (closes #1382038)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6088
diff changeset
    63
    """
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1987
diff changeset
    64
    __regid__ = 'pyvaltable'
1987
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    65
    __select__ = match_kwargs('pyvalue')
7992
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    66
    default_column_renderer_class = PyValTableColRenderer
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    67
    paginable = False # not supported
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    68
    headers = None
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    69
    cssclass = None
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    70
    domid = None
1987
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    71
7992
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    72
    def __init__(self, req, pyvalue, headers=None, cssclass=None,
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    73
                 header_column_idx=None, **kwargs):
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    74
        super(PyValTableView, self).__init__(req, **kwargs)
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    75
        self.pyvalue = pyvalue
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    76
        if headers is not None:
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    77
            self.headers = headers
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    78
        elif self.headers: # headers set on a class attribute, translate
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    79
            self.headers = [self._cw._(header) for header in self.headers]
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    80
        if cssclass is not None:
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    81
            self.cssclass = cssclass
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    82
        self.header_column_idx = header_column_idx
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    83
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    84
    @property
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    85
    def layout_args(self):
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    86
        args = {}
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    87
        if self.cssclass:
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    88
            args['cssclass'] = self.cssclass
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    89
        if self.header_column_idx is not None:
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    90
            args['header_column_idx'] = self.header_column_idx
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    91
        return args
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    92
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    93
    # layout callbacks #########################################################
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    94
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    95
    @property
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    96
    def table_size(self):
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    97
        """return the number of rows (header excluded) to be displayed"""
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    98
        return len(self.pyvalue)
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
    99
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
   100
    @property
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
   101
    def has_headers(self):
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
   102
        return self.headers
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
   103
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
   104
    def build_column_renderers(self):
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
   105
        return [self.column_renderer(colid)
10609
e2d8e81bfe68 [py3k] import range using six.moves
Rémi Cardona <remi.cardona@logilab.fr>
parents: 8190
diff changeset
   106
                for colid in range(len(self.pyvalue[0]))]
7992
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
   107
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
   108
    def facets_form(self, mainvar=None):
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
   109
        return None # not supported
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
   110
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
   111
    def table_actions(self):
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7903
diff changeset
   112
        return [] # not supported
1987
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   113
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   114
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   115
class PyValListView(View):
6802
ff9059e144f9 [pyviews] document the fact that content is not xml-escaped (closes #1382038)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6088
diff changeset
   116
    """display a list of values into an html list.
ff9059e144f9 [pyviews] document the fact that content is not xml-escaped (closes #1382038)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6088
diff changeset
   117
ff9059e144f9 [pyviews] document the fact that content is not xml-escaped (closes #1382038)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6088
diff changeset
   118
    Take care, content is NOT xml-escaped.
ff9059e144f9 [pyviews] document the fact that content is not xml-escaped (closes #1382038)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6088
diff changeset
   119
    """
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1987
diff changeset
   120
    __regid__ = 'pyvallist'
1987
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   121
    __select__ = match_kwargs('pyvalue')
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   122
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   123
    def call(self, pyvalue):
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   124
        self.w(u'<ul>\n')
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   125
        for line in pyvalue:
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   126
            self.w(u'<li>%s</li>\n' % line)
d495e9ce9367 basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   127
        self.w(u'</ul>\n')