author | Nicolas Chauvat <nicolas.chauvat@logilab.fr> |
Tue, 11 Aug 2009 12:42:01 +0200 | |
changeset 2769 | 1800aa0bf396 |
parent 2203 | efdd3a9f9028 |
child 4023 | eae23c40627a |
child 4212 | ab6573088b4a |
permissions | -rw-r--r-- |
0 | 1 |
"""Common subpackage of cubicweb : defines library functions used both on the |
2 |
hg stserver side and on the client side |
|
3 |
||
4 |
:organization: Logilab |
|
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
5 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
0 | 6 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
7 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
0 | 8 |
""" |
9 |
||
10 |
from logilab.common.adbh import FunctionDescr |
|
11 |
||
12 |
from cubicweb._exceptions import * # bw compat |
|
13 |
||
14 |
from rql.utils import register_function, iter_funcnode_variables |
|
15 |
||
16 |
class COMMA_JOIN(FunctionDescr): |
|
17 |
supported_backends = ('postgres', 'sqlite',) |
|
18 |
rtype = 'String' |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1370
diff
changeset
|
19 |
|
0 | 20 |
@classmethod |
2203
efdd3a9f9028
update to new rql get_description api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
21 |
def st_description(cls, funcnode, mainindex, tr): |
efdd3a9f9028
update to new rql get_description api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
22 |
return ', '.join(sorted(term.get_description(mainindex, tr) |
efdd3a9f9028
update to new rql get_description api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
23 |
for term in iter_funcnode_variables(funcnode))) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1370
diff
changeset
|
24 |
|
0 | 25 |
register_function(COMMA_JOIN) # XXX do not expose? |
26 |
||
27 |
||
28 |
class CONCAT_STRINGS(COMMA_JOIN): |
|
29 |
aggregat = True |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1370
diff
changeset
|
30 |
|
0 | 31 |
register_function(CONCAT_STRINGS) # XXX bw compat |
32 |
||
33 |
class GROUP_CONCAT(CONCAT_STRINGS): |
|
34 |
supported_backends = ('mysql', 'postgres', 'sqlite',) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1370
diff
changeset
|
35 |
|
0 | 36 |
register_function(GROUP_CONCAT) |
37 |
||
38 |
||
39 |
class LIMIT_SIZE(FunctionDescr): |
|
40 |
supported_backends = ('postgres', 'sqlite',) |
|
41 |
rtype = 'String' |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1370
diff
changeset
|
42 |
|
0 | 43 |
@classmethod |
2203
efdd3a9f9028
update to new rql get_description api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
44 |
def st_description(cls, funcnode, mainindex, tr): |
efdd3a9f9028
update to new rql get_description api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
45 |
return funcnode.children[0].get_description(mainindex, tr) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1370
diff
changeset
|
46 |
|
0 | 47 |
register_function(LIMIT_SIZE) |
48 |
||
49 |
||
50 |
class TEXT_LIMIT_SIZE(LIMIT_SIZE): |
|
51 |
supported_backends = ('mysql', 'postgres', 'sqlite',) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1370
diff
changeset
|
52 |
|
0 | 53 |
register_function(TEXT_LIMIT_SIZE) |