Merge pull request #2315 from tomchristie/yaml-encoder-fix

YAML encoder fix for 3.0 serializers.
This commit is contained in:
Tom Christie 2014-12-18 12:21:07 +00:00
commit b8bdf812c1

View File

@ -7,6 +7,7 @@ from django.utils import six, timezone
from django.utils.encoding import force_text from django.utils.encoding import force_text
from django.utils.functional import Promise from django.utils.functional import Promise
from rest_framework.compat import OrderedDict from rest_framework.compat import OrderedDict
from rest_framework.utils.serializer_helpers import ReturnDict, ReturnList
import datetime import datetime
import decimal import decimal
import types import types
@ -107,14 +108,14 @@ else:
OrderedDict, OrderedDict,
yaml.representer.SafeRepresenter.represent_dict yaml.representer.SafeRepresenter.represent_dict
) )
# SafeDumper.add_representer( SafeDumper.add_representer(
# DictWithMetadata, ReturnDict,
# yaml.representer.SafeRepresenter.represent_dict yaml.representer.SafeRepresenter.represent_dict
# ) )
# SafeDumper.add_representer( SafeDumper.add_representer(
# OrderedDictWithMetadata, ReturnList,
# yaml.representer.SafeRepresenter.represent_dict yaml.representer.SafeRepresenter.represent_list
# ) )
SafeDumper.add_representer( SafeDumper.add_representer(
types.GeneratorType, types.GeneratorType,
yaml.representer.SafeRepresenter.represent_list yaml.representer.SafeRepresenter.represent_list