pyramid_cubicweb/rest_api.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Tue, 28 Jun 2016 09:44:08 +0200
changeset 11627 1526ae74ab69
parent 11601 23a62d151382
permissions -rw-r--r--
Added tag 0.7.0, debian/0.7.0-1, centos/0.7.0-1 for changeset 0cf2972d2011

from __future__ import absolute_import


from pyramid.httpexceptions import HTTPNotFound
from pyramid.view import view_config
from pyramid_cubicweb.resources import EntityResource, ETypeResource
from pyramid_cubicweb.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__)