Serialization
Every serializable object implements this interface, which is what makes scenes savable to JSON.
Serializable provides the id attribute that every serialized object
carries, and defines two methods for child classes to override:
serialize()— return the object's state as a dictionarydeserialize(data, hashmap)— restore the object from that dictionary
The data uses an OrderedDict rather than a plain dict, so the order of
the parameters in the file is stable.
The classes deriving from Serializable are Scene, Node, Edge, Socket
and the node content widgets.
nodeeditor.node_serializable ¶
A module containing Serializable "Interface". We pretend its an abstract class
Serializable ¶
Class representing the serializable "interface" of NodeEditor.
serialize ¶
Serialization method to serialize this class data into OrderedDict which can be easily stored
in memory or file.
:return: data serialized in OrderedDict
:rtype: OrderedDict
deserialize ¶
Deserialization method which take data in python dict format with helping hashmap containing
references to existing entities.
:param data: Dictionary containing serialized data
:type data: dict
:param hashmap: Helper dictionary containing references (by id == key) to existing objects
:type hashmap: dict
:param restore_id: True if we are creating new Sockets. False is useful when loading existing
Sockets of which we want to keep the existing object's id.
:type restore_id: bool
:return: True if deserialization was successful, otherwise False
:rtype: bool