Show More
@@ -25,6 +25,7 b' from sqlalchemy import UnicodeText' | |||
|
25 | 25 | from sqlalchemy.ext.mutable import Mutable |
|
26 | 26 | |
|
27 | 27 | from rhodecode.lib.ext_json import json |
|
28 | from rhodecode.lib.utils2 import safe_unicode | |
|
28 | 29 | |
|
29 | 30 | |
|
30 | 31 | class JsonRaw(unicode): |
@@ -56,10 +57,12 b' class JSONEncodedObj(sqlalchemy.types.Ty' | |||
|
56 | 57 | |
|
57 | 58 | impl = UnicodeText |
|
58 | 59 | safe = True |
|
60 | enforce_unicode = True | |
|
59 | 61 | |
|
60 | 62 | def __init__(self, *args, **kwargs): |
|
61 | 63 | self.default = kwargs.pop('default', None) |
|
62 | 64 | self.safe = kwargs.pop('safe_json', self.safe) |
|
65 | self.enforce_unicode = kwargs.pop('enforce_unicode', self.enforce_unicode) | |
|
63 | 66 | self.dialect_map = kwargs.pop('dialect_map', {}) |
|
64 | 67 | super(JSONEncodedObj, self).__init__(*args, **kwargs) |
|
65 | 68 | |
@@ -73,6 +76,8 b' class JSONEncodedObj(sqlalchemy.types.Ty' | |||
|
73 | 76 | value = value |
|
74 | 77 | elif value is not None: |
|
75 | 78 | value = json.dumps(value) |
|
79 | if self.enforce_unicode: | |
|
80 | value = safe_unicode(value) | |
|
76 | 81 | return value |
|
77 | 82 | |
|
78 | 83 | def process_result_value(self, value, dialect): |
General Comments 0
You need to be logged in to leave comments.
Login now