Here is what I use (in a file models/0.py):

import pymongo
from pymongo import ASCENDING, DESCENDING

def make_mongo_connection():
    mdb = pymongo.Connection()
    return mdb

mdb = cache.ram('mongodb', make_mongo_connection, 0)

# in the code I use mdb as needed.
# On a busy site, it may make sense to have several of these
connections available to use in a pool

Reply via email to