cubicweb/pyramid/rest_api.py
author Philippe Pepiot <philippe.pepiot@logilab.fr>
Fri, 27 Jan 2017 17:42:16 +0100
changeset 11931 ad7796dabeaa
parent 11811 f09efeead7f9
child 11959 ddc05ce75319
permissions -rw-r--r--
[repository] move cnxset pool handling to a helper class The class has responsability to handle connections pool operations in a single public attribute 'cnxsets'. On Repository _get_cnxset() and _free_cnxset() are replaced by cnxsets.get() and cnxsets.release(). Drop multiple access to private attributes and methods from outside of Repository.

from __future__ import absolute_import


from pyramid.view import view_config
from cubicweb.pyramid.resources import EntityResource, ETypeResource


@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__)