Premi?re version : mise en route du suivi.
[auf_references_client.git] / auf_references_client / serializers.py
1 from django.conf import settings
2 from django.utils.xmlutils import SimplerXMLGenerator
3
4 from django.core.serializers.xml_serializer import Serializer as XMLSerializer, \
5 Deserializer as XMLDeserializer
6
7 class Serializer(XMLSerializer):
8 """
9 A test serializer which removes ``django-objects`` xml tag from default
10 Django's xml serializer, adapt it to your own usage.
11 """
12
13 def start_serialization(self):
14 """
15 Start serialization -- open the XML document and the root element.
16 """
17 self.xml = SimplerXMLGenerator(self.stream, self.options.get("encoding", settings.DEFAULT_CHARSET))
18 self.xml.startDocument()
19 self.xml.startElement("django-test", {"version" : "1.0"})
20
21 def end_serialization(self):
22 """
23 End serialization -- end the document.
24 """
25 self.indent(0)
26 self.xml.endElement("django-test")
27 self.xml.endDocument()
28
29
30 class Deserializer(XMLDeserializer):
31 pass