def customer(request):
    """
    Add the customer to the RequestContext
    """
    msg = "The request object does not contain a customer. Edit your MIDDLEWARE_CLASSES setting to insert 'shop.middlerware.CustomerMiddleware'."
    assert hasattr(request, 'customer'), msg

    context = {
        'customer': request.customer,
        'site_header': settings.SHOP_APP_LABEL.capitalize(),
    }
    if request.user.is_staff:
        try:
            context.update(customer=CustomerModel.objects.get(pk=request.session['emulate_user_id']))
        except (CustomerModel.DoesNotExist, KeyError, __HOLE__):
            pass
    return context
dataset/ETHPy150Open awesto/django-shop/shop/context_processors.py/customer