author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 02 Jun 2010 15:29:18 +0200 | |
changeset 5633 | 879590c52679 |
parent 5424 | 8ecbcbff9777 |
child 6088 | 28f49a4fe702 |
permissions | -rw-r--r-- |
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
|
1 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
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/>. |
1987
d495e9ce9367
basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
18 |
"""Views to display bare python values |
d495e9ce9367
basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
19 |
|
d495e9ce9367
basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
20 |
""" |
d495e9ce9367
basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
21 |
__docformat__ = "restructuredtext en" |
d495e9ce9367
basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
22 |
|
d495e9ce9367
basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
23 |
from cubicweb.view import View |
d495e9ce9367
basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
24 |
from cubicweb.selectors import match_kwargs |
d495e9ce9367
basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
25 |
|
d495e9ce9367
basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
26 |
class PyValTableView(View): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1987
diff
changeset
|
27 |
__regid__ = 'pyvaltable' |
1987
d495e9ce9367
basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
28 |
__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
|
29 |
|
d495e9ce9367
basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
30 |
def call(self, pyvalue, headers=None): |
d495e9ce9367
basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
31 |
if headers is None: |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
32 |
headers = self._cw.form.get('headers') |
4863
f6cf0fcd40ae
[pyviews] add thead/tbody to pyvaltable view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
33 |
w = self.w |
f6cf0fcd40ae
[pyviews] add thead/tbody to pyvaltable view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
34 |
w(u'<table class="listing">\n') |
1987
d495e9ce9367
basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
35 |
if headers: |
4863
f6cf0fcd40ae
[pyviews] add thead/tbody to pyvaltable view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
36 |
w(u'<thead>') |
f6cf0fcd40ae
[pyviews] add thead/tbody to pyvaltable view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
37 |
w(u'<tr>') |
1987
d495e9ce9367
basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
38 |
for header in headers: |
4863
f6cf0fcd40ae
[pyviews] add thead/tbody to pyvaltable view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
39 |
w(u'<th>%s</th>' % header) |
f6cf0fcd40ae
[pyviews] add thead/tbody to pyvaltable view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
40 |
w(u'</tr>\n') |
f6cf0fcd40ae
[pyviews] add thead/tbody to pyvaltable view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
41 |
w(u'</thead>') |
f6cf0fcd40ae
[pyviews] add thead/tbody to pyvaltable view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
42 |
w(u'<tbody>') |
1987
d495e9ce9367
basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
43 |
for row in pyvalue: |
4863
f6cf0fcd40ae
[pyviews] add thead/tbody to pyvaltable view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
44 |
w(u'<tr>') |
1987
d495e9ce9367
basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
45 |
for cell in row: |
4863
f6cf0fcd40ae
[pyviews] add thead/tbody to pyvaltable view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
46 |
w(u'<td>%s</td>' % cell) |
f6cf0fcd40ae
[pyviews] add thead/tbody to pyvaltable view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
47 |
w(u'</tr>\n') |
f6cf0fcd40ae
[pyviews] add thead/tbody to pyvaltable view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
48 |
w(u'</tbody>') |
f6cf0fcd40ae
[pyviews] add thead/tbody to pyvaltable view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
49 |
w(u'</table>\n') |
1987
d495e9ce9367
basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
50 |
|
d495e9ce9367
basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
51 |
|
d495e9ce9367
basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
52 |
class PyValListView(View): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1987
diff
changeset
|
53 |
__regid__ = 'pyvallist' |
1987
d495e9ce9367
basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
54 |
__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
|
55 |
|
d495e9ce9367
basic views for python values (eg without any result set)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
56 |
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
|
57 |
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
|
58 |
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
|
59 |
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
|
60 |
self.w(u'</ul>\n') |