Added __getstate__ and __setstate__ to set and Channel.

This commit is contained in:
Jeremy Fincher 2003-04-09 18:57:25 +00:00
parent 64b60dceae
commit f4d187b1f1
2 changed files with 17 additions and 0 deletions

View File

@ -140,6 +140,12 @@ class set(object):
except KeyError:
pass
def __getstate__(self):
return self.d
def __setstate__(self, d):
self.d = d
class queue(dict):
"""An FIFO Queue, O(1) for all operations."""

View File

@ -151,6 +151,17 @@ class Channel(object):
self.halfops.discard(user)
self.voices.discard(user)
def __getstate__(self):
return (self.topic, self.users, self.ops, self.halfops, self.voices)
def __setstate__(self, (topic, users, ops, halfops, voices)):
self.topic = topic
self.users = users
self.ops = ops
self.halfops = halfops
self.voices = voices
class IrcState(object):
"""Maintains state of the Irc connection. Should also become smarter.
"""