changeset 4447:9d37875416c3

python2.3 compatibility fixes
author Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
date Thu, 21 Oct 2010 20:31:13 +0000
parents 17f796a78647
children 2784c239e6c8
files roundup/anypy/email_.py roundup/backends/back_anydbm.py roundup/roundupdb.py
diffstat 3 files changed, 23 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/roundup/anypy/email_.py	Thu Oct 21 20:31:13 2010 +0000
@@ -0,0 +1,19 @@
+try:
+    # Python 2.5+
+    from email.parser import FeedParser
+except ImportError:
+    # Python 2.4
+    try :
+        from email.Parser import FeedParser
+    except ImportError:
+        from email.Parser import Parser
+        class FeedParser:
+            def __init__(self):
+                self.content = []
+
+            def feed(self, s):
+                self.content.append(s)
+
+            def close(self):
+                p = Parser()
+                return p.parsestr(''.join(self.content))
--- a/roundup/backends/back_anydbm.py	Thu Oct 21 19:53:51 2010 +0000
+++ b/roundup/backends/back_anydbm.py	Thu Oct 21 20:31:13 2010 +0000
@@ -158,7 +158,9 @@
 
     def getclasses(self):
         """Return a list of the names of all existing classes."""
-        return sorted(self.classes)
+        l = self.classes.keys()
+        l.sort()
+        return l
 
     def getclass(self, classname):
         """Get the Class object representing a particular class.
--- a/roundup/roundupdb.py	Thu Oct 21 19:53:51 2010 +0000
+++ b/roundup/roundupdb.py	Thu Oct 21 20:31:13 2010 +0000
@@ -31,12 +31,7 @@
 from email.MIMEText import MIMEText
 from email.MIMEBase import MIMEBase
 
-try:
-    # Python 2.5+
-    from email.parser import FeedParser
-except ImportError:
-    # Python 2.4
-    from email.Parser import FeedParser
+from anypy.email_ import FeedParser
 
 from roundup import password, date, hyperdb
 from roundup.i18n import _

Roundup Issue Tracker: http://roundup-tracker.org/