[Pypi-checkins] r963 - trunk/pypi

richard python-checkins at python.org
Tue Aug 23 09:10:43 CEST 2011


Author: richard
Date: Tue Aug 23 09:10:43 2011
New Revision: 963

Modified:
   trunk/pypi/store.py
Log:
handle missing cookie data

Modified: trunk/pypi/store.py
==============================================================================
--- trunk/pypi/store.py	(original)
+++ trunk/pypi/store.py	Tue Aug 23 09:10:43 2011
@@ -1801,7 +1801,12 @@
         cursor = self.get_cursor()
         safe_execute(cursor, 'select cookie from cookies where name=%s',
                 (username,))
-        cookie = cursor.fetchall()[0][0]
+        try:
+            cookie = cursor.fetchall()[0][0]
+        except IndexError:
+            # no cookie, make one
+            cookie = ''.join(random.choice(alphanum) for i in range(10))
+
         # create random data 
         rand = [random.choice(alphanum) for i in range(12)]
         rand.append(str(int(time.time())))


More information about the Pypi-checkins mailing list