cubicweb/pyramid/rest_api.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 04 Oct 2016 13:14:35 +0200
changeset 11783 8865c9e55575
parent 11631 faf279e33298
child 11811 f09efeead7f9
permissions -rw-r--r--
[massive store] docstring and __init__ cleanup

from __future__ import absolute_import


from pyramid.httpexceptions import HTTPNotFound
from pyramid.view import view_config
from cubicweb.pyramid.resources import EntityResource, ETypeResource
from cubicweb.pyramid.predicates import MatchIsETypePredicate


@view_config(
    route_name='cwentities',
    context=EntityResource,
    request_method='DELETE')
def delete_entity(context, request):
    context.rset.one().cw_delete()
    request.response.status_int = 204
    return request.response


def includeme(config):
    config.add_route(
        'cwentities', '/{etype}/*traverse',
        factory=ETypeResource.from_match('etype'), match_is_etype='etype')
    config.scan(__name__)