Ticket #5711: serialize_extra_support.diff
File serialize_extra_support.diff, 2.4 KB (added by , 17 years ago) |
---|
-
core/serializers/json.py
23 23 def end_serialization(self): 24 24 self.options.pop('stream', None) 25 25 self.options.pop('fields', None) 26 self.options.pop('extra', None) 26 27 simplejson.dump(self.objects, self.stream, cls=DjangoJSONEncoder, **self.options) 27 28 28 29 def getvalue(self): -
core/serializers/base.py
30 30 31 31 self.stream = options.get("stream", StringIO()) 32 32 self.selected_fields = options.get("fields") 33 33 self.select_extra = options.get("extra", False) 34 34 35 self.start_serialization() 35 36 for obj in queryset: 36 37 self.start_object(obj) … … 46 47 if field.serialize: 47 48 if self.selected_fields is None or field.attname in self.selected_fields: 48 49 self.handle_m2m_field(obj, field) 50 if self.select_extra and queryset._select is not None: 51 for field in queryset._select.keys(): 52 self.handle_extra(obj, field) 49 53 self.end_object(obj) 50 54 self.end_serialization() 51 55 return self.getvalue() -
core/serializers/pyyaml.py
20 20 def end_serialization(self): 21 21 self.options.pop('stream', None) 22 22 self.options.pop('fields', None) 23 self.options.pop('extra', None) 23 24 yaml.dump(self.objects, self.stream, **self.options) 24 25 25 26 def getvalue(self): -
core/serializers/python.py
34 34 35 35 def handle_field(self, obj, field): 36 36 self._current[field.name] = smart_unicode(getattr(obj, field.name), strings_only=True) 37 38 def handle_extra(self, obj, field): 39 self._current[field] = smart_unicode(getattr(obj, field), strings_only=True) 37 40 38 41 def handle_fk_field(self, obj, field): 39 42 related = getattr(obj, field.name)