Initial import to Tizen
[profile/ivi/python-twisted.git] / doc / core / howto / listings / pb / copy2_classes.py
1 #!/usr/bin/env python
2
3 # Copyright (c) Twisted Matrix Laboratories.
4 # See LICENSE for details.
5
6 from twisted.spread import pb
7
8 class FrogPond:
9     def __init__(self, numFrogs, numToads):
10         self.numFrogs = numFrogs
11         self.numToads = numToads
12     def count(self):
13         return self.numFrogs + self.numToads
14
15 class SenderPond(FrogPond, pb.Copyable):
16     def getStateToCopy(self):
17         d = self.__dict__.copy()
18         d['frogsAndToads'] = d['numFrogs'] + d['numToads']
19         del d['numFrogs']
20         del d['numToads']
21         return d
22
23 class ReceiverPond(pb.RemoteCopy):
24     def setCopyableState(self, state):
25         self.__dict__ = state
26     def count(self):
27         return self.frogsAndToads
28
29 pb.setUnjellyableForClass(SenderPond, ReceiverPond)