threeohclock / google-app-engine-django

Automatically exported from code.google.com/p/google-app-engine-django
Apache License 2.0
0 stars 0 forks source link

Django XML serializer does not namespace georss properly #54

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create model class and save an instance to the datastore
2. Import serializers from django.core
3. Serialize <model>.all() queryset via serializers.serialize("xml",
<model>.all())

--Example--
from django.core import serializers
from appengine_django.models import BaseModel
from google.appengine.ext import db

class ExampleModel(BaseModel):
   name = db.StringProperty()
   age  = db.IntegerProperty()
   location = db.GeoPtProperty()

inst = ExampleModel(name='Some Guy', age=28, location=db.GeoPt(10,20))
inst.save()

myStr = serializers.serialize("xml", ExampleModel.all())
print myStr
objs = serializers.deserialize("xml", myStr)
objs.next()

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File
"/Users/jeff.hall/Source/workspace/Google/SVGadget/appengine_django/serializer/x
ml.py",
line 96, in next
    for event, node in self.event_stream:
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/xml/dom/
pulldom.py",
line 232, in next
    rc = self.getEvent()
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/xml/dom/
pulldom.py",
line 265, in getEvent
    self.parser.feed(buf)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/xml/sax/
expatreader.py",
line 211, in feed
    self._err_handler.fatalError(exc)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/xml/sax/
handler.py",
line 38, in fatalError
    raise exception
SAXParseException: <unknown>:6:48: unbound prefix

What is the expected output? 
 * Successful serialization and deserialization of objects 
 * XML representation similar to below (note the xmlns declaration):

<?xml version="1.0" encoding="utf-8"?>
<django-objects version="1.0" xmlns:georss="http://www.georss.org/georss">
<entity kind="examplemodel"
key="ahdzdHJlZXR2aWV3Z2FkZ2V0YmFja2VuZHISCxIMRXhhbXBsZU1vZGVsGAgM">

<key>tag:xxxOMITxxx,2008-06-20:ExampleModel[ahdzdHJlZXR2aWV3Z2FkZ2V0YmFja2VuZHIS
CxIMRXhhbXBsZU1vZGVsGAgM]</key>
  <property name="age" type="int">28</property>
  <property name="location" type="georss:point"><georss:point>20.0
30.0</georss:point></property>
  <property name="name" type="string">Some Guy</property>
</entity>
<entity kind="examplemodel"
key="ahdzdHJlZXR2aWV3Z2FkZ2V0YmFja2VuZHISCxIMRXhhbXBsZU1vZGVsGAkM">

<key>tag:xxxOMITxxx,2008-06-20:ExampleModel[ahdzdHJlZXR2aWV3Z2FkZ2V0YmFja2VuZHIS
CxIMRXhhbXBsZU1vZGVsGAkM]</key>
  <property name="age" type="int">15</property>
  <property name="location" type="georss:point"><georss:point>22.0
33.0</georss:point></property>
  <property name="name" type="string">Some Kid</property>
</entity>
</django-objects>

What do you see instead?
SAXParseException: <unknown>:6:48: unbound prefix

XML representation lacks xmlns declaration for georss namespace.

What version of the product are you using? On what operating system?
App Engine SDK v1.1.0.1 - Mac OS X 10.5.3

Please provide any additional information below.

Find patch to appengine_django/serializer/xml.py as attachment.

Original issue reported on code.google.com by zenchic...@live.com on 20 Jun 2008 at 6:47

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by mattbrow...@gmail.com on 24 Jun 2008 at 11:00