1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
# note: this module is shared with the listeners so they can understand the data passed in
class CustomData(object):
serialized_classname = "blobdispatch.CustomData"
def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c
def to_dict(self):
"""for (serpent) serialization"""
return {
"__class__": self.serialized_classname,
"a": self.a,
"b": self.b,
"c": self.c
}
@classmethod
def from_dict(cls, classname, d):
"""for (serpent) deserialization"""
assert classname == cls.serialized_classname
obj = cls(d["a"], d["b"], d["c"])
return obj
|