diff roundup/cgi/client.py @ 4980:13f8f88ad984

Replace rfc822 imports with email package (issue2550870) The rfc822 package has been deprecated since Python v2.3 in favour of the email package.
author John Kristensen <john@jerrykan.com>
date Fri, 27 Feb 2015 00:48:25 +1100
parents f1a2bd1dea77
children 494d255043c9
line wrap: on
line diff
--- a/roundup/cgi/client.py	Mon Mar 16 16:16:02 2015 +0100
+++ b/roundup/cgi/client.py	Fri Feb 27 00:48:25 2015 +1100
@@ -3,8 +3,9 @@
 __docformat__ = 'restructuredtext'
 
 import base64, binascii, cgi, codecs, mimetypes, os
-import quopri, random, re, rfc822, stat, sys, time
+import quopri, random, re, stat, sys, time
 import socket, errno
+import email.utils
 from traceback import format_exc
 
 try:
@@ -495,7 +496,8 @@
                 #    date = time.time() - 1
                 #else:
                 #    date = time.time() + 5
-                self.additional_headers['Expires'] = rfc822.formatdate(date)
+                self.additional_headers['Expires'] = \
+                    email.utils.formatdate(date, usegmt=True)
 
                 # render the content
                 self.write_html(self.renderContext())
@@ -1074,7 +1076,7 @@
 
         # spit out headers
         self.additional_headers['Content-Type'] = mime_type
-        self.additional_headers['Last-Modified'] = rfc822.formatdate(lmt)
+        self.additional_headers['Last-Modified'] = email.utils.formatdate(lmt)
 
         ims = None
         # see if there's an if-modified-since...
@@ -1085,7 +1087,7 @@
             # cgi will put the header in the env var
             ims = self.env['HTTP_IF_MODIFIED_SINCE']
         if ims:
-            ims = rfc822.parsedate(ims)[:6]
+            ims = email.utils.parsedate(ims)[:6]
             lmtt = time.gmtime(lmt)[:6]
             if lmtt <= ims:
                 raise NotModified

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