diff gpp/core/functions.py @ 241:27bee3ac85e6

For #93: fix url scheme for downloads.
author Brian Neal <bgneal@gmail.com>
date Wed, 15 Sep 2010 01:01:40 +0000
parents 423c39ee44e0
children e3958aacd8dd
line wrap: on
line diff
--- a/gpp/core/functions.py	Wed Sep 15 00:14:54 2010 +0000
+++ b/gpp/core/functions.py	Wed Sep 15 01:01:40 2010 +0000
@@ -80,3 +80,16 @@
         ip = match.group(1) if match else None
 
     return ip
+
+
+def get_page(qdict):
+    """Attempts to retrieve the value for "page" from the given query dict and
+    return it as an integer. If the key cannot be found or converted to an
+    integer, 1 is returned.
+    """
+    n = qdict.get('page', 1)
+    try:
+        n = int(n)
+    except ValueError:
+        n = 1
+    return n