I upgraded TMDA's python email lib to v4.0.1, and it broke something in tmda-cgi. It seems View.py was using Message.get_type(), which even in the old version we were using before this upgrade, was a deprecated method. Just silently deprecated though, so things still worked. But when I upgraded, that method was no longer there.

Message.get_content_type() is what replaces it. See http://docs.python.org/lib/module-email.message.html

Review the attached diff and see if that's correct. It does allow tmda-cgi to work again (I tested). I also grepped through the tmda-cgi source for other deprecated methods (http://docs.python.org/lib/email-pkg-history.html) and didn't find any, so hopefully this is the only change that's required.

I'll hold off on checking this in until I hear from you. Or if you prefer another fix, by all means do that instead.
Index: View.py
===================================================================
--- View.py	(revision 2075)
+++ View.py	(working copy)
@@ -59,10 +59,10 @@
   elif SoundType1.search(Filename): Icon = "sound"
   elif TextType1.search(Filename): Icon = "text"
   elif ZipType1.search(Filename): Icon = "zip"
-  elif ImageType2.search(Part.get_type("text/plain")): Icon = "image"
-  elif MovieType2.search(Part.get_type("text/plain")): Icon = "movie"
-  elif SoundType2.search(Part.get_type("text/plain")): Icon = "sound"
-  elif ZipType2.search(Part.get_type("text/plain")): Icon = "zip"
+  elif ImageType2.search(Part.get_content_type()): Icon = "image"
+  elif MovieType2.search(Part.get_content_type()): Icon = "movie"
+  elif SoundType2.search(Part.get_content_type()): Icon = "sound"
+  elif ZipType2.search(Part.get_content_type()): Icon = "zip"
   Attachment["Icon"]     = Icon
   Attachment["Filename"] = Filename
   Attachment["Size"]     = CgiUtil.Size(MsgSize = len(Part.as_string()))
@@ -331,12 +331,12 @@
 
   # Display this part
   if Part.is_multipart():
-    if Part.get_type("multipart/mixed") == "multipart/alternative":
+    if Part.get_content_type() == "multipart/alternative":
       # Pick preferred alternative
       PrefPart   = None
       PrefRating = -1
       for SubPart in Part.get_payload():
-        Type = SubPart.get_type("text/plain")
+        Type = SubPart.get_content_type()
         Rating = PVars[("ViewPending", "AltPref")].find(Type)
         # Is this part preferred?
         if (not PrefPart) or ((PrefRating == -1) and (Rating >= 0)) \
@@ -350,7 +350,7 @@
       for SubPart in Part.get_payload():
         ShowPart(SubPart)
   else:
-    Type = Part.get_type("text/plain")
+    Type = Part.get_content_type()
     # Display the easily display-able parts
     if Type == "text/html":
       # Sterilize & display
_________________________________________________
tmda-workers mailing list ([email protected])
http://tmda.net/lists/listinfo/tmda-workers

Reply via email to