File: customdata.py

package info (click to toggle)
pyro4 4.82-2
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 2,528 kB
  • sloc: python: 17,736; makefile: 169; sh: 113; javascript: 62
file content (26 lines) | stat: -rw-r--r-- 696 bytes parent folder | download | duplicates (5)
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