diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2017-03-24 21:59:23 +0100 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2017-03-24 21:59:23 +0100 |
commit | fa511457866b36bf3686d9398495371363672b77 (patch) | |
tree | 1b95b362952588e5ad5e812136d7614696e9f5e3 | |
parent | 46832b96a5ed60a1299f4450a01688d74e56d17e (diff) |
Use http.cookies with fallback to Cookie.
-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') |