[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[minion-cvs] Switch to forward-compatible DeliveryPacket format.



Update of /home/minion/cvsroot/src/minion/lib/mixminion/server
In directory moria.mit.edu:/tmp/cvs-serv15636/lib/mixminion/server

Modified Files:
	PacketHandler.py 
Log Message:
Switch to forward-compatible DeliveryPacket format.

Index: PacketHandler.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/PacketHandler.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- PacketHandler.py	31 Aug 2003 19:29:29 -0000	1.25
+++ PacketHandler.py	3 Sep 2003 15:54:40 -0000	1.26
@@ -290,15 +290,25 @@
         self.dPayload = None
         self.error = None
 
+    def __getstate__(self):
+        return "V0", self.__dict__
+        
     def __setstate__(self, state):
-        self.__dict__.update(state)
-        # XXXX006 remove
-        if not hasattr(self, 'isfrag'):
-            self.isfrag = 0
-        if not hasattr(self, 'dPayload'):
-            self.dPayload = None
-        if not hasattr(self, 'error'):
-            self.error = None
+        if type(state) == types.DictType:
+            #XXXX006 remove this case.
+            self.__dict__.update(state)
+            if not hasattr(self, 'isfrag'):
+                self.isfrag = 0
+            if not hasattr(self, 'dPayload'):
+                self.dPayload = None
+            if not hasattr(self, 'error'):
+                self.error = None
+            if not hasattr(self, 'headers'):
+                self.headers = {}
+        elif state[0] == 'V0':
+            self.__dict__.update(state[1])
+        else:
+            raise MixError("Unrecognized state version %s", state[0])
 
     def isDelivery(self):
         """Return true iff this packet is a delivery (non-relay) packet."""
@@ -406,7 +416,9 @@
         """Return a dict containing the headers for this message."""
         if self.type is None:
             self.decode()
-        assert self.headers is not None
+        if self.headers is None:
+            LOG.warn("getHeaders found no decoded headers")
+            return {}
         return self.headers
 
     def getAsciiTag(self):