-
Notifications
You must be signed in to change notification settings - Fork 3
Setting of metadata of referenced objects during saving is not possible #17
Description
If you are saving object a which has a reference to object b, but b has not been saved yet, it is not possible to set metadata on b in the save_instance_state call of a because mincepy will try finding b's obj_id and fail.
This is quite restrictive and it would be useful to be able to set the metadata of referenced objects in certain scenarios.
One possible way to implement it would be to have the transaction keep track of metadata operations using a weakref dict (in addition to the obj_id tracking). This way if, by the end of the trasnaction, the object does have an object id (because save is called on it somewhere during the transaction), then the metadata will also be saved. The one downside with this is that, if the object is not saved during the transaction then the metadata will be silently lost.