On 8/9/07, Shawn Allen <[EMAIL PROTECTED]> wrote:
>
> Hey everyone,
>
> I'm about to tackle an API that supports multiple response formats
> using serializers. I realize that the API (as simple as it is) is
> subject to change, but it seems like a totally sensible pattern for
> what I'd like to do. One problem I've come across already is that the
> base Serializer class's serialize() method assumes whatever is passed
> to it is an iterable. This is a poor assumption in the case of my
> API, which, in many cases, will be returning a serialized
> representation of a single object. Can anyone recommend a strategy
> for overriding this behavior?

Adding serialization of single objects would be a reasonable addition
to the Django serialization framework. There could be some devil in
the details (especially on deserialization), but at a conceptual
level, I don't see why we couldn't modify serialize() to check:

if data is iterable:
    serialize list
else
    serialize object

Patches welcome.

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to