cubicweb/pyramid/rest_api.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 09 Nov 2016 11:42:33 +0100
branch3.24
changeset 11811 f09efeead7f9
parent 11631 faf279e33298
child 11959 ddc05ce75319
permissions -rw-r--r--
Fix broken flake8 configuration and flake8 errors which were hidden by this breakage. flake8 --filename options doesn't work as expected: * it's expected to be a shell pattern, using stdlib's fnmatch.fnmatch function internally. This funciton thinks that 'cubicweb/x.py' doesn't match 'cubicweb/x.py' (there must be a reason but that's not the point), hence no file was actually checked ; * as this is a list of pattern, each encountered file is checked against each pattern, leading to run time explosion. So maintain list of files to check in a separated file and give this list to flake8 using unix's xarg command.
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__)