equal
deleted
inserted
replaced
20 """ |
20 """ |
21 |
21 |
22 __docformat__ = "restructuredtext en" |
22 __docformat__ = "restructuredtext en" |
23 _ = unicode |
23 _ = unicode |
24 |
24 |
25 import sys |
|
26 if sys.version_info < (2,6): |
|
27 import simplejson as json |
|
28 else: |
|
29 import json |
|
30 |
|
31 dumps = json.dumps |
|
32 |
|
33 from urllib import quote as urlquote |
25 from urllib import quote as urlquote |
34 |
26 |
35 from logilab.common.deprecation import deprecated |
27 from logilab.common.deprecation import deprecated |
36 |
28 |
37 from cubicweb.web._exceptions import * |
29 from cubicweb.web._exceptions import * |
38 from cubicweb.utils import CubicWebJsonEncoder |
30 from cubicweb.utils import json_dumps |
|
31 |
|
32 dumps = deprecated('[3.9] use cubicweb.utils.json_dumps instead of dumps')(json_dumps) |
39 |
33 |
40 INTERNAL_FIELD_VALUE = '__cubicweb_internal_field__' |
34 INTERNAL_FIELD_VALUE = '__cubicweb_internal_field__' |
41 |
35 |
42 |
36 |
43 class stdmsgs(object): |
37 class stdmsgs(object): |
61 LOGGER = getLogger('cubicweb.web') |
55 LOGGER = getLogger('cubicweb.web') |
62 |
56 |
63 # XXX deprecated |
57 # XXX deprecated |
64 FACETTES = set() |
58 FACETTES = set() |
65 |
59 |
66 |
|
67 def json_dumps(value): |
|
68 return dumps(value, cls=CubicWebJsonEncoder) |
|
69 |
60 |
70 def jsonize(function): |
61 def jsonize(function): |
71 def newfunc(*args, **kwargs): |
62 def newfunc(*args, **kwargs): |
72 value = function(*args, **kwargs) |
63 value = function(*args, **kwargs) |
73 try: |
64 try: |