author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 09 Nov 2016 11:42:33 +0100 | |
branch | 3.24 |
changeset 11811 | f09efeead7f9 |
parent 11631 | faf279e33298 |
child 11959 | ddc05ce75319 |
permissions | -rw-r--r-- |
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__) |