# -*- coding: utf-8 -*-

from .models.nonrel import User


def mongodb_user(request):

    if request.user.is_anonymous():
        return {u'mongodb_user': None}

    try:
        mongodb_user = User.objects.get(id=request.session[u'mongodb_user_id'])

    except KeyError:
        mongodb_user = User.objects.get(django_user=request.user.id)

        # Cache it for next time.
        request.session[u'mongodb_user_id'] = mongodb_user.id

    return {u'mongodb_user': mongodb_user}

# -*- coding: utf-8 -*-


def mongodb_user(request):
    """ not the most usefull context manager in the world. """

    if request.user.is_anonymous():
        return {u'mongodb_user': None}

    return {u'mongodb_user': request.user.mongo}

Simplify the context processor. Not very useful anymore, in fact.
Simplify the context processor. Not very useful anymore, in fact.
