This is what the documentation on Scripted objects say.
Code: Select all
def __getstate__(self):
'''When saving the document this object gets stored using Python's json module.\
Since we have some un-serializable parts here -- the Coin stuff -- we must define this method\
to return a tuple of all serializable objects or None.'''
return None
def __setstate__(self,state):
'''When restoring the serialized object from document we have the chance to set some internals here.\
Since no data were serialized nothing needs to be done here.'''
return None
There are places talking about "serializing" but this doesn't mean anything to me. Is there somewhere that describes this in detail?
I also remember reading some old documentation that in the past objects where "serialized" using Python's pickle module. I suppose this was changed to json at some point. Or what is the history behind this?
So, this all seems like magic to me, it works, but I don't know why.
In Draft, there are several scripted objects, with various methods but no comments. I don't understand what all those methods do, so for the most part I don't touch them so they keep working like usual.