#9389: Cannot specify extra arguments when deserializing.
---------------------------+------------------------------------------------
Reporter: johnnyleitrim | Owner: nobody
Status: new | Milestone:
Component: Serialization | Version: 1.0
Keywords: | Stage: Unreviewed
Has_patch: 0 |
---------------------------+------------------------------------------------
I wrote my own custom serializer. I can pass my Serializer parameters
when I make a call to it:
{{{ serializers.serialize("my_format", queryset, my_param = my_value) }}}
I can get the value of my_param in my Serializer class.
However, I cannot do the same when deserializing. This is because the
deserialize method in {{{ django.core.serializer.__init__.py}}} does not
accept any extra parameters:
{{{
def deserialize(format, stream_or_string):
"""
Deserialize a stream or a string. Returns an iterator that yields
``(obj,
m2m_relation_dict)``, where ``obj`` is a instantiated -- but
*unsaved* --
object, and ``m2m_relation_dict`` is a dictionary of
``{m2m_field_name :
list_of_related_objects}``.
"""
d = get_deserializer(format)
return d(stream_or_string)
}}}
I think that this should be changed to allow for optional parameters:
{{{
def deserialize(format, stream_or_string, **options):
"""
Deserialize a stream or a string. Returns an iterator that yields
``(obj,
m2m_relation_dict)``, where ``obj`` is a instantiated -- but
*unsaved* --
object, and ``m2m_relation_dict`` is a dictionary of
``{m2m_field_name :
list_of_related_objects}``.
"""
d = get_deserializer(format)
return d(stream_or_string, **options)
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/9389>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---