15.2.126. camcops_server.cc_modules.cc_response

camcops_server/cc_modules/cc_response.py


Copyright (C) 2012-2020 Rudolf Cardinal (rudolf@pobox.com).

This file is part of CamCOPS.

CamCOPS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

CamCOPS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with CamCOPS. If not, see <https://www.gnu.org/licenses/>.


Implements a Pyramid Response object customized for CamCOPS.

class camcops_server.cc_modules.cc_response.CamcopsResponse(camcops_request: CamcopsRequest, **kwargs)[source]

Response class, inheriting from Pyramid’s response.

We do this mainly to set the HTTP Content-Security-Policy header to match the nonce set by the :class:camcops_server.cc_modules.cc_request.CamcopsRequest.

However, once this class exists, it may as well set all the standard headers, rather than using additional middleware.

__init__(camcops_request: CamcopsRequest, **kwargs) → None[source]

Initialize self. See help(type(self)) for accurate signature.

camcops_server.cc_modules.cc_response.camcops_response_factory(request: CamcopsRequest) → pyramid.response.Response[source]

Factory function to make a response object.