Don't use mutables in constants or parameters

This commit is contained in:
Guillaume Ayoub 2016-09-02 11:04:29 +02:00
parent e6433ec970
commit 68e1e9dfb2

View File

@ -50,23 +50,30 @@ from . import auth, rights, storage, xmlutils
VERSION = "2.0.0rc0" VERSION = "2.0.0rc0"
NOT_ALLOWED = (client.FORBIDDEN, {"Content-type": "text/plain"}, NOT_ALLOWED = (
"Access to the requested resource forbidden.") client.FORBIDDEN, (("Content-type", "text/plain"),),
NOT_FOUND = (client.NOT_FOUND, {"Content-type": "text/plain"}, "Access to the requested resource forbidden.")
"The requested resource could not be found.") NOT_FOUND = (
WEBDAV_PRECONDITION_FAILED = (client.CONFLICT, {"Content-type": "text/plain"}, client.NOT_FOUND, (("Content-type", "text/plain"),),
"WebDAV precondition failed.") "The requested resource could not be found.")
PRECONDITION_FAILED = (client.PRECONDITION_FAILED, WEBDAV_PRECONDITION_FAILED = (
{"Content-type": "text/plain"}, "Precondition failed.") client.CONFLICT, (("Content-type", "text/plain"),),
REQUEST_TIMEOUT = (client.REQUEST_TIMEOUT, {"Content-type": "text/plain"}, "WebDAV precondition failed.")
"Connection timed out.") PRECONDITION_FAILED = (
REQUEST_ENTITY_TOO_LARGE = (client.REQUEST_ENTITY_TOO_LARGE, client.PRECONDITION_FAILED,
{"Content-type": "text/plain"}, (("Content-type", "text/plain"),), "Precondition failed.")
"Request body too large.") REQUEST_TIMEOUT = (
REMOTE_DESTINATION = (client.BAD_GATEWAY, {"Content-type": "text/plain"}, client.REQUEST_TIMEOUT, (("Content-type", "text/plain"),),
"Remote destination not supported.") "Connection timed out.")
DIRECTORY_LISTING = (client.FORBIDDEN, {"Content-type": "text/plain"}, REQUEST_ENTITY_TOO_LARGE = (
"Directory listings are not supported.") client.REQUEST_ENTITY_TOO_LARGE, (("Content-type", "text/plain"),),
"Request body too large.")
REMOTE_DESTINATION = (
client.BAD_GATEWAY, (("Content-type", "text/plain"),),
"Remote destination not supported.")
DIRECTORY_LISTING = (
client.FORBIDDEN, (("Content-type", "text/plain"),),
"Directory listings are not supported.")
DAV_HEADERS = "1, 2, 3, calendar-access, addressbook, extended-mkcol" DAV_HEADERS = "1, 2, 3, calendar-access, addressbook, extended-mkcol"
@ -264,8 +271,8 @@ class Application:
def __call__(self, environ, start_response): def __call__(self, environ, start_response):
"""Manage a request.""" """Manage a request."""
def response(status, headers={}, answer=None): def response(status, headers=(()), answer=None):
headers = headers.copy() headers = dict(headers)
# Set content length # Set content length
if answer: if answer:
self.logger.debug("Response content:\n%s", answer) self.logger.debug("Response content:\n%s", answer)