]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commit
Pecan: Streamline request body processing
authorSalvatore Orlando <salv.orlando@gmail.com>
Fri, 6 Nov 2015 21:57:32 +0000 (13:57 -0800)
committerSalvatore Orlando <salv.orlando@gmail.com>
Mon, 11 Jan 2016 12:07:34 +0000 (04:07 -0800)
commit0f9a607cf6eeefab5a571f517a01c50f98a3ce16
tree603960fbbb6ccecb7be9c1ef1a44c0afc538d0d4
parent5def2dcd74cce79672c487c6242ef46bfb516d1e
Pecan: Streamline request body processing

This patch simplifies the process for validating the request body for
POST and PUT requests and preparing it for dispatching to plugins.

In particular it removes the need for parsing the URL to find the
resource identifier, and instead leverages Pecan's routing engine
to extract it. As a result the attribute population hook now simply
deals with request body validation, and has been renamed accordingly.

The logic for loading the current state of the object from the plugin
in order to enforce authZ policy on PUT requests has been moved to
the appropriate hook, PolicyEnforcementHook.

The logic for managing plural/singular names for resource has also been
improved, and two helper functions to retrieve a resource's attributes
have been added to neutron.api.v2.attributes

The logic for aborting requests with unsupported HTTP methods has also
been moved to the REST controllers. It used to be in PolicyEnforcementHook,
which was probably not the right thing to do.

This patch also unskips a functional test concerning ownership checks,
and add functional tests for verifying correct request processing.
Unit tests for the newly added helper functions are also provided.

Related blueprint wsgi-pecan-switch

Change-Id: Ib26998b37bdeec8af7a97f77b66d421b8cd271da
neutron/api/v2/attributes.py
neutron/pecan_wsgi/app.py
neutron/pecan_wsgi/controllers/root.py
neutron/pecan_wsgi/hooks/__init__.py
neutron/pecan_wsgi/hooks/attribute_population.py [deleted file]
neutron/pecan_wsgi/hooks/body_validation.py [new file with mode: 0644]
neutron/pecan_wsgi/hooks/ownership_validation.py
neutron/pecan_wsgi/hooks/policy_enforcement.py
neutron/pecan_wsgi/hooks/quota_enforcement.py
neutron/tests/functional/pecan_wsgi/test_functional.py
neutron/tests/unit/api/v2/test_attributes.py