def test_tree_serialize(self): """test serialization of models with foreign keys""" ser = RecursiveXmlSerializer() res = TestModel.objects.all() xml = ser.serialize(res) assert (md5(xml).hexdigest() == CONFIRMED_XML_DIGEST)
def test_tree_serialize(self): """test serialization of models with foreign keys""" ser = RecursiveXmlSerializer() res = TestModel.objects.all() xml = ser.serialize(res) assert md5(xml).hexdigest() == CONFIRMED_XML_DIGEST
def test___serialize__(self): "A model with a __serialize__ method should serialize it self" tags = TagModel.objects.all().order_by('id') ser = RecursiveXmlSerializer() self.assertEqual( ser.serialize(tags), '<django-objects version="1.0"><taggy>good</taggy><taggy>bad</taggy><taggy>ugly</taggy></django-objects>' )
def test___serialize__(self): "A model with a __serialize__ method should serialize it self" tags = TagModel.objects.all().order_by("id") ser = RecursiveXmlSerializer() self.assertEqual( ser.serialize(tags), '<django-objects version="1.0"><taggy>good</taggy><taggy>bad</taggy><taggy>ugly</taggy></django-objects>', )
def __xml__(self): """turn querysets into xml recursively""" ser = RecursiveXmlSerializer() return ser.serialize(self)
def __xml__(self): """turn model object into xml recursively""" ser = RecursiveXmlSerializer() return ser.serialize([self])
def feed(request): ser = RecursiveXmlSerializer() return HttpResponse(ser.serialize(PageBase.objects.all()), mimetype='text/xml')