Opened 16 years ago

Closed 16 years ago

#8607 closed (fixed)

yaml serialization to file fails

Reported by: antony_hatchkins Owned by: nobody
Component: Core (Serialization) Version: dev
Severity: Keywords: yaml
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When serializing anything to yaml with stream=open('file','w') it fails with the following error:

XMLSerializer = serializers.get_serializer('yaml')
serializer = XMLSerializer()
serializer.serialize(Partner.objects.all(), stream=open('partners.yaml', 'w'))

Traceback (most recent call last):

File "./bin/serialization/serialize_partners.py", line 16, in <module>

serializer.serialize(Partner.objects.all(), stream=out)

File "/var/django/phones-lev/django/core/serializers/base.py", line 56, in serialize

return self.getvalue()

File "./django/core/serializers/pyyaml.py", line 43, in getvalue

return self.stream.getvalue()

AttributeError: 'file' object has no attribute 'getvalue'

Attachments (2)

pyyaml.py (1.9 KB ) - added by antony_hatchkins <antony.hatchkins@…> 16 years ago.
django\core\serializers\pyyaml.py
yaml-serialization-to-file.diff (531 bytes ) - added by antony_hatchkins <antony.hatchkins@…> 16 years ago.
svn diff vs django r8671 which fixes the issue

Download all attachments as: .zip

Change History (3)

by antony_hatchkins <antony.hatchkins@…>, 16 years ago

Attachment: pyyaml.py added

django\core\serializers\pyyaml.py

by antony_hatchkins <antony.hatchkins@…>, 16 years ago

svn diff vs django r8671 which fixes the issue

comment:1 by antony_hatchkins <antony.hatchkins@…>, 16 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top