Пример #1
0
def respond_if_blocked(context, request):
    """
    Set 410 Gone and construct response if resource is deleted or hidden.

    Otherwise or it request method is 'options' or 'put' return None
    """
    if request.method not in ['HEAD', 'GET', 'POST']:
        return
    block_reason = get_reason_if_blocked(context)
    if block_reason is not None:
        raise HTTPGone(detail=block_reason)
Пример #2
0
def respond_if_blocked(context, request):
    """
    Set 410 Gone and construct response if resource is deleted or hidden.

    Otherwise or it request method is 'options' or 'put' return None
    """
    from adhocracy_core.utils import get_reason_if_blocked
    if request.method not in ['HEAD', 'GET', 'POST']:
        return
    block_reason = get_reason_if_blocked(context)
    if block_reason is not None:
        raise HTTPGone(detail=block_reason)
Пример #3
0
def respond_if_blocked(context, request):
    """
    Set 410 Gone and construct response if resource is deleted or hidden.

    Otherwise or it request method is 'options' or 'put' return None
    """
    from adhocracy_core.utils import get_reason_if_blocked

    if request.method not in ["HEAD", "GET", "POST"]:
        return
    block_reason = get_reason_if_blocked(context)
    if block_reason is not None:
        raise HTTPGone(detail=block_reason)
Пример #4
0
def etag_blocked(context: IResource, request: IRequest) -> str:
    """Return `resource` blocked status."""
    reason = get_reason_if_blocked(context)
    return str(reason)
Пример #5
0
def _validate_visibility(context: IResource, request: IRequest):
    if request.method not in ['HEAD', 'GET', 'POST']:
        return
    block_reason = get_reason_if_blocked(context)
    if block_reason is not None:
        raise HTTPGone(detail=block_reason)
Пример #6
0
def etag_blocked(context: IResource, request: IRequest) -> str:
    """Return `resource` blocked status."""
    reason = get_reason_if_blocked(context)
    return str(reason)
Пример #7
0
def _validate_visibility(context: IResource, request: IRequest):
    if request.method not in ['HEAD', 'GET', 'POST']:
        return
    block_reason = get_reason_if_blocked(context)
    if block_reason is not None:
        raise HTTPGone(detail=block_reason)