>    One of my principle was to let user define any possible structure.
> Ex
> <object>
> <a>
> <b>
> <c>
> <name>Django</name>
> </c>
> </b>
> </a>
> </object>
>
> 1. With Meta.structure you can do:
> def name
>    return Django
> structure="a[b[c[name__field]]]
>
> 2. Without:
> def a
>    return BFieldSerializer
> class BFieldSerializer
>    def b

If you switch to a two phase serialize you can get this for free:

def a(instance):
  return {'b': {'c': {'name': instance.name}}}

and then you can exclude name if you don't want it appearing as a
naked key. You seemed to hit on this yourself later in your reply, so
forge onwards.

> Yes, in my solution anything at the end of first phaze will be Python base
> type, BaseFieldSerialize subclass or BaseModelSerializer subclass with
> resolved Meta.structure. If I remove Meta.structure it will be even
> simplier. I can resolve Base(Model/Field)Serializer only when i know to what
> format it will be serialized.

I think we mean different things by "phase." You are describing the
first phase as resolving the serializer into a python class instance.
We are considering the first phase to be serializing a model instance
into python primitive types, before serializing it to a textual
format.

-Alex Ogier

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

Reply via email to