def restore_csrf_token(request, storage=None):
    """
    Given the request and a the context used during the second render phase,
    this wil check if there is a CSRF cookie and restores if needed, to
    counteract the way the CSRF framework invalidates the CSRF token after
    each request/response cycle.
    """
    if storage is None:
        storage = {}
    try:
        request.META["CSRF_COOKIE"] = request.COOKIES[settings.CSRF_COOKIE_NAME]
    except __HOLE__:
        csrf_token = storage.get('csrf_token', None)
        if csrf_token:
            request.META["CSRF_COOKIE"] = csrf_token
    return storage
dataset/ETHPy150Open codysoyland/django-phased/phased/utils.py/restore_csrf_token