aboutsummaryrefslogtreecommitdiffstats
path: root/servo
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2015-08-18 23:35:53 +0300
committerFilipp Lepalaan <filipp@mac.com>2015-08-18 23:35:53 +0300
commit50fe15e2747c5b9f81e17cb389ccf74f589d4671 (patch)
treeaf92314822ea9d519e283cdd1713d99f8014030c /servo
parent2e2e8b3e38a893550929f6e57f67dfdb0a3a3f6b (diff)
downloadServo-50fe15e2747c5b9f81e17cb389ccf74f589d4671.tar.gz
Servo-50fe15e2747c5b9f81e17cb389ccf74f589d4671.tar.bz2
Servo-50fe15e2747c5b9f81e17cb389ccf74f589d4671.zip
Added custom session serializer
Diffstat (limited to 'servo')
-rw-r--r--servo/lib/utils.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/servo/lib/utils.py b/servo/lib/utils.py
index 20da7d5..ed77897 100644
--- a/servo/lib/utils.py
+++ b/servo/lib/utils.py
@@ -24,6 +24,17 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
+import json
+from django.db.models import Model
+from django.core.serializers.json import DjangoJSONEncoder
+
+
+def multiprint(*args):
+ """
+ Emulate JS console.log()
+ """
+ print(', '.join(args))
+
def choices_to_dict(t):
"""
Converts a ChoiceField two-tuple to a dict (for JSON)
@@ -51,3 +62,11 @@ def cache_getset(k, v):
val = v()
cache.set(k, val)
return val
+
+
+class SessionSerializer:
+ def dumps(self, obj):
+ return json.dumps(obj, cls=DjangoJSONEncoder)
+
+ def loads(self, data):
+ return json.loads(data, cls=DjangoJSONEncoder)