author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Wed, 17 Jun 2009 20:46:37 +0200 | |
branch | stable |
changeset 2114 | 862f27d94af4 |
parent 1977 | 606923dff11b |
child 2203 | efdd3a9f9028 |
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 |
21 |
def st_description(cls, funcnode): |
|
22 |
return ', '.join(term.get_description() |
|
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 |
44 |
def st_description(cls, funcnode): |
|
45 |
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
|
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) |