Allow setting the resulting dict class.#6
Allow setting the resulting dict class.#6dourvaris wants to merge 1 commit intodanielholmstrom:masterfrom
Conversation
|
I cannot figure out why anyone would like to use a custom dict class. If you want to, as in your use case, use an OrderedDict then what would determine the order? And why would you care for the order? |
Well firstly this is not limited to ordered dicts only, you could pass any type of class that would be used as the base for the output dict which makes, a good example would be something like https://github.com/dimagi/jsonobject. Using a JsonObject class, the resulting dict like object for json could follow a strict schema of fields in the final json output (to catch bugs early) and it can also do automatic 2-way deserialization of datetime so that python side If you must ask why not just call the class on the resulting dict from dictalchemy, sure, but then you would also have to follow all the relationships etc. in essence reimplement dictalchemy.utils.asdict.
You could ask the same question about why OrderedDict exists in the first place, yet it exists. A simple issue would be when displaying/formatting the dict, you would like the order to be fixed and usually the more important fields higher up. eg. vs Order would be determined by |
Main use case would be something like: