
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}



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.

- 
- from .models.nonrel import User
  
  
  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}
-     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}
- 
Simplify the context processor. Not very useful anymore, in fact.
## Code Before:

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}

## Instruction:
Simplify the context processor. Not very useful anymore, in fact.
## Code After:


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}
