cubicweb/pyramid/rest_api.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 30 Sep 2016 17:34:59 +0200
changeset 11781 4ebd968f364c
parent 11631 faf279e33298
child 11811 f09efeead7f9
permissions -rw-r--r--
[massive store] Reintroduce methods that are necessary to properly handle master/slave configuration Related to #15538303

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__)