|
|
|
@ -15,9 +15,9 @@ from datetime import datetime
|
|
|
|
|
from werkzeug.http import http_date, parse_date |
|
|
|
|
from werkzeug.datastructures import CallbackDict |
|
|
|
|
from . import Markup, json |
|
|
|
|
from ._compat import iteritems, text_type |
|
|
|
|
|
|
|
|
|
from itsdangerous import URLSafeTimedSerializer, BadSignature |
|
|
|
|
import six |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def total_seconds(td): |
|
|
|
@ -63,16 +63,16 @@ class TaggedJSONSerializer(object):
|
|
|
|
|
elif isinstance(value, uuid.UUID): |
|
|
|
|
return {' u': value.hex} |
|
|
|
|
elif callable(getattr(value, '__html__', None)): |
|
|
|
|
return {' m': six.text_type(value.__html__())} |
|
|
|
|
return {' m': text_type(value.__html__())} |
|
|
|
|
elif isinstance(value, list): |
|
|
|
|
return [_tag(x) for x in value] |
|
|
|
|
elif isinstance(value, datetime): |
|
|
|
|
return {' d': http_date(value)} |
|
|
|
|
elif isinstance(value, dict): |
|
|
|
|
return dict((k, _tag(v)) for k, v in six.iteritems(value)) |
|
|
|
|
return dict((k, _tag(v)) for k, v in iteritems(value)) |
|
|
|
|
elif isinstance(value, str): |
|
|
|
|
try: |
|
|
|
|
return six.text_type(value) |
|
|
|
|
return text_type(value) |
|
|
|
|
except UnicodeError: |
|
|
|
|
raise UnexpectedUnicodeError(u'A byte string with ' |
|
|
|
|
u'non-ASCII data was passed to the session system ' |
|
|
|
@ -85,7 +85,7 @@ class TaggedJSONSerializer(object):
|
|
|
|
|
def object_hook(obj): |
|
|
|
|
if len(obj) != 1: |
|
|
|
|
return obj |
|
|
|
|
the_key, the_value = six.advance_iterator(obj.iteritems()) |
|
|
|
|
the_key, the_value = next(iteritems(obj)) |
|
|
|
|
if the_key == ' t': |
|
|
|
|
return tuple(the_value) |
|
|
|
|
elif the_key == ' u': |
|
|
|
|