Skip to content

Instantly share code, notes, and snippets.

@pr4v33n
Created July 27, 2011 10:21
Show Gist options
  • Save pr4v33n/1109094 to your computer and use it in GitHub Desktop.
Save pr4v33n/1109094 to your computer and use it in GitHub Desktop.
gen expr
def next_top_post(request):
data = ''
post_id = request.GET['post_id']
post = Post.objects.get(id=post_id)
posts = get_top_posts(request)
matches = itertools.dropwhile(lambda p: p.id != post.id, posts)
matched = next(itertools.islice(matches, 1, None), None)
arrows = get_top_arrows(matched)
next_post = profile_post_to_html(request,matched,'top')
data = {'post':next_post, 'arrows':arrows}
return HttpResponse(json.dumps(data), mimetype="application/json")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment