Skip to content

Instantly share code, notes, and snippets.

@wcarss
Created April 11, 2012 16:56
Show Gist options
  • Save wcarss/2360514 to your computer and use it in GitHub Desktop.
Save wcarss/2360514 to your computer and use it in GitHub Desktop.
still ugly
def get_list(resource, base_url = ''):
# hit db in real life
total_items = 45
try:
page_number = int(request.args.get('page', 1))
except ValueError, e:
# we want an int; if we can't make an int, assume page 1
page_number = 1
# we index from 1, so fix non-positive numbers
if page_number < 1:
page_number = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment