author | Katia Saurfelt <katia.saurfelt@logilab.fr> |
Tue, 19 May 2009 14:31:42 +0200 | |
branch | stable |
changeset 1868 | af1ae863606d |
parent 1802 | d628defebc17 |
child 1977 | 606923dff11b |
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 |
|
1370 | 5 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
0 | 6 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
7 |
""" |
|
8 |
||
9 |
from logilab.common.adbh import FunctionDescr |
|
10 |
||
11 |
from cubicweb._exceptions import * # bw compat |
|
12 |
||
13 |
from rql.utils import register_function, iter_funcnode_variables |
|
14 |
||
15 |
class COMMA_JOIN(FunctionDescr): |
|
16 |
supported_backends = ('postgres', 'sqlite',) |
|
17 |
rtype = 'String' |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1370
diff
changeset
|
18 |
|
0 | 19 |
@classmethod |
20 |
def st_description(cls, funcnode): |
|
21 |
return ', '.join(term.get_description() |
|
22 |
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
|
23 |
|
0 | 24 |
register_function(COMMA_JOIN) # XXX do not expose? |
25 |
||
26 |
||
27 |
class CONCAT_STRINGS(COMMA_JOIN): |
|
28 |
aggregat = True |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1370
diff
changeset
|
29 |
|
0 | 30 |
register_function(CONCAT_STRINGS) # XXX bw compat |
31 |
||
32 |
class GROUP_CONCAT(CONCAT_STRINGS): |
|
33 |
supported_backends = ('mysql', 'postgres', 'sqlite',) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1370
diff
changeset
|
34 |
|
0 | 35 |
register_function(GROUP_CONCAT) |
36 |
||
37 |
||
38 |
class LIMIT_SIZE(FunctionDescr): |
|
39 |
supported_backends = ('postgres', 'sqlite',) |
|
40 |
rtype = 'String' |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1370
diff
changeset
|
41 |
|
0 | 42 |
@classmethod |
43 |
def st_description(cls, funcnode): |
|
44 |
return funcnode.children[0].get_description() |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1370
diff
changeset
|
45 |
|
0 | 46 |
register_function(LIMIT_SIZE) |
47 |
||
48 |
||
49 |
class TEXT_LIMIT_SIZE(LIMIT_SIZE): |
|
50 |
supported_backends = ('mysql', 'postgres', 'sqlite',) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1370
diff
changeset
|
51 |
|
0 | 52 |
register_function(TEXT_LIMIT_SIZE) |