Hi, I am Vivek Narayanan, an undergrad student at IIT, Varanasi in India and am interested in participating in this year's SoC
Problem ------------ Django provides a serialization framework that is very useful for loading and saving fixtures, but not very flexible if one wants to provide an API for a Django application or use a serialization format different from what is defined by Django. Also the current handling of foreign keys and many to many relationships is not really useful outside the context of fixtures. Solution ------------ I propose a class based Serializer, extending/refactoring the current base class which would be entirely configurable by the user. I would also like to provide some configurations for XML and JSON/YAML, that can serve as building blocks for writing other serializers. The class would have the following configurable options: • A basic structure, markup or template representing each field an object and also representing the object. • An external wrapping structure, a structure for an array, delimiters and assignment symbols. • Arbitrary level of nesting depth, Which fields of related models are to be represented? etc. This nesting can be handled by recursion. The data about related models can be extracted in the start_object or end_object methods. • Choosing which datatypes to dump as is, which ones to convert to something else. The user can provide a mapping between types in the form of a dict and conversion functions when needed. • Adding metadata about each field, like data-type or content-length; this can be represented as additional attributes in a tag in XML or arrays in a key-value representation. This can be done by adding some class methods. • The level of indentation. The idea is to store them as a python list or list of dicts till the final 'dumping' stage. This way we can still use existing libraries like SimpleXML, SimpleJSON etc. This 'dumping' method would be overrideable. The user would have to choose between using a standard library and specifying a format. I would also like to add a couple of features: • An exclude argument, which would be a list of fields to exclude from the model, this would also contain the fields to exclude in related models. I would like to extend the fields argument in the same way. • An extras argument, which would allow properties and data returned by some methods to be serialized. While this is by no means a complete proposal, I was looking for some feedback on the idea and would be happy to incorporate your suggestions. -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.