cubicweb/pyramid/rest_api.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Mon, 20 Mar 2017 17:38:43 +0100
branch3.24
changeset 12077 e282711ac6b2
parent 11811 f09efeead7f9
child 11959 ddc05ce75319
permissions -rw-r--r--
Added tag 3.24.7, debian/3.24.7-1, centos/3.24.7-1 for changeset 58f1e8545a77
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11596
1f2570f1d72a [routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     1
from __future__ import absolute_import
1f2570f1d72a [routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     2
1f2570f1d72a [routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     3
11599
f8ba6ea94af9 [refactoring] Move EntityResource and ETypeResource to a separate module
Rabah Meradi <rabah.meradi@logilab.fr>
parents: 11598
diff changeset
     4
from pyramid.view import view_config
11631
faf279e33298 Merge with pyramid-cubicweb
Yann Voté <yann.vote@logilab.fr>
parents: 11601
diff changeset
     5
from cubicweb.pyramid.resources import EntityResource, ETypeResource
11596
1f2570f1d72a [routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     6
1f2570f1d72a [routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     7
1f2570f1d72a [routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     8
@view_config(
1f2570f1d72a [routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     9
    route_name='cwentities',
1f2570f1d72a [routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    10
    context=EntityResource,
1f2570f1d72a [routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    11
    request_method='DELETE')
1f2570f1d72a [routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    12
def delete_entity(context, request):
1f2570f1d72a [routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    13
    context.rset.one().cw_delete()
1f2570f1d72a [routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    14
    request.response.status_int = 204
1f2570f1d72a [routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    15
    return request.response
1f2570f1d72a [routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    16
1f2570f1d72a [routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    17
1f2570f1d72a [routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    18
def includeme(config):
1f2570f1d72a [routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    19
    config.add_route(
1f2570f1d72a [routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    20
        'cwentities', '/{etype}/*traverse',
1f2570f1d72a [routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    21
        factory=ETypeResource.from_match('etype'), match_is_etype='etype')
1f2570f1d72a [routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    22
    config.scan(__name__)