author | Denis Laxalde <denis.laxalde@logilab.fr> |
Wed, 29 Mar 2017 11:45:19 +0200 | |
branch | 3.25 |
changeset 12112 | 0a54f49314f6 |
parent 11967 | 83739be20fab |
child 12911 | a17cbf539a69 |
permissions | -rw-r--r-- |
11967
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11959
diff
changeset
|
1 |
# copyright 2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11959
diff
changeset
|
2 |
# copyright 2014-2016 UNLISH S.A.S. (Montpellier, FRANCE), all rights reserved. |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11959
diff
changeset
|
3 |
# |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11959
diff
changeset
|
4 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11959
diff
changeset
|
5 |
# |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11959
diff
changeset
|
6 |
# This file is part of CubicWeb. |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11959
diff
changeset
|
7 |
# |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11959
diff
changeset
|
8 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11959
diff
changeset
|
9 |
# terms of the GNU Lesser General Public License as published by the Free |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11959
diff
changeset
|
10 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11959
diff
changeset
|
11 |
# any later version. |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11959
diff
changeset
|
12 |
# |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11959
diff
changeset
|
13 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11959
diff
changeset
|
14 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11959
diff
changeset
|
15 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11959
diff
changeset
|
16 |
# details. |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11959
diff
changeset
|
17 |
# |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11959
diff
changeset
|
18 |
# You should have received a copy of the GNU Lesser General Public License along |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11959
diff
changeset
|
19 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11959
diff
changeset
|
20 |
|
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11959
diff
changeset
|
21 |
"""Experimental REST API for CubicWeb using Pyramid.""" |
83739be20fab
[pyramid] Add a copyright and docstring to all modules
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11959
diff
changeset
|
22 |
|
11596
1f2570f1d72a
[routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
23 |
from __future__ import absolute_import |
1f2570f1d72a
[routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
24 |
|
1f2570f1d72a
[routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
25 |
|
11599
f8ba6ea94af9
[refactoring] Move EntityResource and ETypeResource to a separate module
Rabah Meradi <rabah.meradi@logilab.fr>
parents:
11598
diff
changeset
|
26 |
from pyramid.view import view_config |
11631
faf279e33298
Merge with pyramid-cubicweb
Yann Voté <yann.vote@logilab.fr>
parents:
11601
diff
changeset
|
27 |
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
|
28 |
|
1f2570f1d72a
[routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
29 |
|
1f2570f1d72a
[routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
30 |
@view_config( |
1f2570f1d72a
[routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
31 |
route_name='cwentities', |
1f2570f1d72a
[routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
32 |
context=EntityResource, |
1f2570f1d72a
[routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
33 |
request_method='DELETE') |
1f2570f1d72a
[routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
34 |
def delete_entity(context, request): |
1f2570f1d72a
[routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
35 |
context.rset.one().cw_delete() |
1f2570f1d72a
[routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
36 |
request.response.status_int = 204 |
1f2570f1d72a
[routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
37 |
return request.response |
1f2570f1d72a
[routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
38 |
|
1f2570f1d72a
[routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
39 |
|
1f2570f1d72a
[routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
40 |
def includeme(config): |
11959
ddc05ce75319
[pyramid] Include 'cubicweb.pyramid.predicates' where it is used
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11811
diff
changeset
|
41 |
config.include('.predicates') |
11596
1f2570f1d72a
[routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
42 |
config.add_route( |
1f2570f1d72a
[routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
43 |
'cwentities', '/{etype}/*traverse', |
1f2570f1d72a
[routes] Add a 'cwentities' route with traversal
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
44 |
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
|
45 |
config.scan(__name__) |