I need to store instances (or at least their state) in a database. The idea is that I should be able to re-create the instance on demand. Since I define the classes, I can choose how I would like to store the data.
Consider the following diagram, inheritance diagram:
A
/ \
B C
/\ /\
D E F ...
The idea is that the instance can belong to any of those classes and can itself store other objects (that I have completely design control over).
My first thought is to store the state exclusively in a dictionary, dump the dictionary into a json and store it in the database. At run time, load json from the database convert it to dictionary, create an object passing in the dictionary that get's setup and so on...
I'm not sure if that is a good approach, and also if there are any other issues that might crop up. I already came across one, where if you use myobj.dict you don't actually get all the class' parent's attributes though...
Any suggestions?