node_serializable Module

A module containing Serializable “Interface”. We pretend its an abstract class

class nodeeditor.node_serializable.Serializable

Bases: object

Default constructor automatically creates data which are common to any serializable object. In our case we create self.id which we use in every object in NodeEditor.

id

We set this property in the constructor because all of NodeEditor’s serializable objects use this attribute to unique object identification. It is handy for referencing objects.

serialize() → collections.OrderedDict

Serialization method to serialize this class data into OrderedDict which can be easily stored in memory or file.

Returns:data serialized in OrderedDict
Return type:OrderedDict
deserialize(data: dict, hashmap: dict = {}, restore_id: bool = True) → bool

Deserialization method which take data in python dict format with helping hashmap containing references to existing entities.

Parameters:
  • data (dict) – Dictionary containing serialized data
  • hashmap (dict) – Helper dictionary containing references (by id == key) to existing objects
  • restore_id (bool) – 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.
Returns:

True if deserialization was successful, otherwise False

Return type:

bool