Skip to content

Instantly share code, notes, and snippets.

View SamLiu79's full-sized avatar

SamLiu SamLiu79

  • ActiveNetwork
  • Xi'an
View GitHub Profile
@SamLiu79
SamLiu79 / gist:958502
Created May 6, 2011 05:49
paginator compatible with pymongo and mongoengine
# pagination.py
class Paginator(object):
def __init__(self, query, per_page):
"""Initialize a paginator.
Arguments:
- query -- queryset from pymongo or mongoengine
- per_page -- number of items per page
#!/usr/bin/env python
#-*- coding: utf-8 -*-
"""
Use it by setting CACHE_BACKEND in settings.py, e.g.:
CACHE_BACKEND = 'utils.backends.cache.pylibmcd://127.0.0.1:11211/'
NEW: can be transmit pylibmc cache behaviors to cache backend
for example: