diff options
-rw-r--r-- | pastepy.py | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -1,5 +1,8 @@ import cgi -import Cookie +try: + from http.cookies import SimpleCookie +except ImportError: + from Cookie import SimpleCookie import datetime import db import mimetypes @@ -73,7 +76,7 @@ class Paste(object): }) def paste(self): - c = Cookie.SimpleCookie(self.environ['HTTP_COOKIE'] if 'HTTP_COOKIE' in self.environ else None) + c = SimpleCookie(self.environ['HTTP_COOKIE'] if 'HTTP_COOKIE' in self.environ else None) if self.environ['REQUEST_METHOD'] == 'POST': mp = cgi.FieldStorage(fp = self.environ['wsgi.input'], environ = self.environ, keep_blank_values = True) if mp['type'].value == 'Preview': @@ -127,7 +130,7 @@ class Paste(object): session.close() headers = [('Location', '/view/%s' % hash)] - c = Cookie.SimpleCookie() + c = SimpleCookie() c['nick'] = nick dt = (datetime.datetime.utcnow() + datetime.timedelta(days = 30)) if 'remember_me' in mp else datetime.datetime.utcfromtimestamp(0) c['nick']['expires'] = dt.strftime('%a, %d-%b-%y %H:%M:%S GMT') |