Exemple #1
0
def put_view(request, url_factory=url_factory):
    """Once again url_factory is only here for hooking in tests"""
    ## TODO: Factor me!!
    try:
        url = url_factory(request)
        location = route_url('put', request, url)
        response = HTTPCreated(location=location)
    except NoURLSupplied:
        ## TODO: verify this is the right HTTP response.
        response = HTTPPreconditionFailed("no url was supplied")
    except (HTTPNotFound, HTTPPreconditionFailed), e:
        response = e
Exemple #2
0
def create_post_view(request, url_factory=url_factory):
    """url_factory arg only for testing purposes"""
    ## TODO: Factor me!!
    try:
        url = url_factory(request)
        response = Response(content_type='text/plain',
                            body=route_url('post', request, url))
    except NoURLSupplied:
        ## TODO: verify this is the right HTTP response.
        return HTTPPreconditionFailed("no url was supplied")
    except (HTTPNotFound, HTTPPreconditionFailed), e:
        return e