Called as each object is handled.
(self, obj)
| 47 | self.xml.endDocument() |
| 48 | |
| 49 | def start_object(self, obj): |
| 50 | """ |
| 51 | Called as each object is handled. |
| 52 | """ |
| 53 | if not hasattr(obj, "_meta"): |
| 54 | raise base.SerializationError( |
| 55 | "Non-model object (%s) encountered during serialization" % type(obj) |
| 56 | ) |
| 57 | |
| 58 | self.indent_level += 1 |
| 59 | self.indent(self.indent_level) |
| 60 | attrs = {"model": str(obj._meta)} |
| 61 | if not self.use_natural_primary_keys or not self._resolve_natural_key(obj): |
| 62 | obj_pk = obj.pk |
| 63 | if obj_pk is not None: |
| 64 | attrs["pk"] = obj._meta.pk.value_to_string(obj) |
| 65 | |
| 66 | self.xml.startElement("object", attrs) |
| 67 | |
| 68 | def end_object(self, obj): |
| 69 | """ |
nothing calls this directly
no test coverage detected