cubicweb/pyramid/rest_api.py
changeset 11631 faf279e33298
parent 11601 23a62d151382
child 11811 f09efeead7f9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/pyramid/rest_api.py	Mon Sep 26 14:52:12 2016 +0200
@@ -0,0 +1,24 @@
+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__)