Malcolm Tredinnick wrote:
> > I am trying to serialize some model data with the output going to a
> > file. I am doing it the way its suggested in the documentation.
> >
> > XMLSerializer = serializers.get_serializer("xml")
> > xml_serializer = XMLSerializer()
> > out = open("file.xml", "w")
> > xml_serializer.serialize(SomeModel.objects.all(), stream=out)
> >
> > This throws an AttributeError-
> > Traceback (most recent call last):
> > File "<console>", line 1, in ?
> > File "/home/ram/jasmine/Django-0.95/django/core/serializers/
> > base.py", line 50, in serialize
> > return self.getvalue()
> > File "/home/ram/jasmine/Django-0.95/django/core/serializers/
> > base.py", line 110, in getvalue
> > return self.stream.getvalue()
> > AttributeError: 'file' object has no attribute 'getvalue'
> >
> > Looking into base.py, I found that the serialize function attempts to
> > return the entire data using getvalue function of the stream it wrote
> > to. That works for StringIO which is used if one doesn't pass a
> > stream, but not for a file object.
> >
> > This doesn't look like an intentional behavior. Am I missing
> > something?
>
> This was bug #3435, fixed in [5075]. Since we only fixed it a month ago
> (April 25), the fix isn't in 0.95 or 0.96. However, you could look at
> that changeset and manually patch your local copy yourself if you wanted
> to.
Thanks Malcolm.
Regards,
Ramashish
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---