Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serializers should be format-specific #1024

Open
monokrome opened this issue Aug 30, 2013 · 0 comments
Open

Serializers should be format-specific #1024

monokrome opened this issue Aug 30, 2013 · 0 comments

Comments

@monokrome
Copy link

A Serializer should be defined in a way that is format-specific, instead of representing a "has-many" relationship in one Serializer, the current supported Serializers should be composed of many Serializer objects.

Right now, if I wanted to use two third party Serializers, I need to create some middle-ground object that merges them together. The real need is to be able to treat serializers much like middleware.

TASTYPIE_SERIALIZERS = [
    'tastypie.serializers.json.Serializer',
    'tastypie.serializers.xml.Serializer',
    'tastypie.serializers.yaml.Serializer',
    'thirdpartylibrary.serializers.msgpack.Serializer',
    'thirdpartylibrary.serializers..Serializer',
    'myproject.serializers.protobuf.Serializer'
]

If you need to define Resource-specific Serializer objects, you should be able to define them as such:

from tastypie.serializers import json, xml

class MyResource(ModelResource):
    class Meta(object):
        serializers = [
            xml.Serializer,
            json.Serializer,
        ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant