From 9d193b6b30c3eed3374776d488d321ab85e56d03 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Fri, 3 Aug 2012 00:29:06 +0200 Subject: [PATCH 1/6] Don't start Radicale when PID file exists (fixes #890) --- radicale/__main__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/radicale/__main__.py b/radicale/__main__.py index b2a0da6f..175f6133 100644 --- a/radicale/__main__.py +++ b/radicale/__main__.py @@ -91,6 +91,8 @@ def run(): # Fork if Radicale is launched as daemon if options.daemon: + if options.pid and os.path.exists(options.pid): + raise OSError("PID file exists: %s" % options.pid) pid = os.fork() if pid: try: From a7481a054613be85fe5f5b96f73e521d926bedf5 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Fri, 3 Aug 2012 11:52:30 +0200 Subject: [PATCH 2/6] Clean the server's __call__ method, with comments and better variable names --- radicale/__init__.py | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/radicale/__init__.py b/radicale/__init__.py index 47c649a6..0ba6be22 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -211,18 +211,23 @@ class Application(object): else: user = password = None - last_allowed = None - collections = [] - for collection in items: - if not isinstance(collection, ical.Collection): - if last_allowed: - collections.append(collection) + last_collection_allowed = None + allowed_items = [] + for item in items: + if not isinstance(item, ical.Collection): + # item is not a colleciton, it's the child of the last + # collection we've met in the loop. Only add this item if + # this last collection was allowed. + if last_collection_allowed: + allowed_items.append(item) continue + # item is a collection + collection = item if collection.owner in acl.PUBLIC_USERS: log.LOGGER.info("Public collection") - collections.append(collection) - last_allowed = True + allowed_items.append(collection) + last_collection_allowed = True else: log.LOGGER.info( "Checking rights for collection owned by %s" % ( @@ -230,18 +235,18 @@ class Application(object): if self.acl.has_right(collection.owner, user, password): log.LOGGER.info( "%s allowed" % (user or "Anonymous user")) - collections.append(collection) - last_allowed = True + allowed_items.append(collection) + last_collection_allowed = True else: log.LOGGER.info( "%s refused" % (user or "Anonymous user")) - last_allowed = False + last_collection_allowed = False - if collections: - # Collections found + if allowed_items: + # Collections and items found status, headers, answer = function( - environ, collections, content, user) - elif user and last_allowed is None: + environ, allowed_items, content, user) + elif user and last_collection_allowed is None: # Good user and no collections found, redirect user to home location = "/%s/" % str(quote(user)) log.LOGGER.info("redirecting to %s" % location) From f593ab0fbd1de0899c6f20702699d24bbcef7ed3 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Fri, 3 Aug 2012 13:55:52 +0200 Subject: [PATCH 3/6] Set the maximuml line length to 79 instead of 80 --- .pylintrc | 2 +- radicale/acl/courier.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pylintrc b/.pylintrc index 5faf833d..3b459a4a 100644 --- a/.pylintrc +++ b/.pylintrc @@ -89,7 +89,7 @@ generated-members= [FORMAT] # Maximum number of characters on a single line. -max-line-length=80 +max-line-length=79 # Maximum number of lines in a module max-module-lines=1000 diff --git a/radicale/acl/courier.py b/radicale/acl/courier.py index 1b1926f3..7ffc0744 100644 --- a/radicale/acl/courier.py +++ b/radicale/acl/courier.py @@ -58,6 +58,6 @@ def has_right(owner, user, password): return True # default is reject - # this alleviates the problem of a possibly empty reply from courier authlib + # this alleviates the problem of a possibly empty reply from authlib # see http://www.courier-mta.org/authlib/README_authlib.html#authpipeproto return False From 7ae764fd4b34e93d8fd5510a20f0f825d872e62c Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Fri, 3 Aug 2012 14:08:11 +0200 Subject: [PATCH 4/6] Enhance readability according to PEP8 --- radicale/__init__.py | 4 ++-- radicale/config.py | 8 ++++---- radicale/xmlutils.py | 22 ++++++++++------------ 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/radicale/__init__.py b/radicale/__init__.py index 0ba6be22..28ef953a 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -172,7 +172,7 @@ class Application(object): def __call__(self, environ, start_response): """Manage a request.""" log.LOGGER.info("%s request at %s received" % ( - environ["REQUEST_METHOD"], environ["PATH_INFO"])) + environ["REQUEST_METHOD"], environ["PATH_INFO"])) headers = pprint.pformat(self.headers_log(environ)) log.LOGGER.debug("Request headers:\n%s" % headers) @@ -439,7 +439,7 @@ class Application(object): # Evolution bug workaround etag = environ.get("HTTP_IF_MATCH", "").replace("\\", "") if (not item and not etag) or ( - item and ((etag or item.etag) == item.etag)): + item and ((etag or item.etag) == item.etag)): # PUT allowed in 3 cases # Case 1: No item and no ETag precondition: Add new item # Case 2: Item and ETag precondition verified: Modify item diff --git a/radicale/config.py b/radicale/config.py index d6677712..c484e9ba 100644 --- a/radicale/config.py +++ b/radicale/config.py @@ -68,10 +68,10 @@ INITIAL_CONFIG = { "courier_socket": ""}, "storage": { "type": "filesystem", - "filesystem_folder": - os.path.expanduser("~/.config/radicale/collections"), - "git_folder": - os.path.expanduser("~/.config/radicale/collections")}, + "filesystem_folder": os.path.expanduser( + "~/.config/radicale/collections"), + "git_folder": os.path.expanduser( + "~/.config/radicale/collections")}, "logging": { "config": "/etc/radicale/logging", "debug": "False", diff --git a/radicale/xmlutils.py b/radicale/xmlutils.py index 3399002b..102c442a 100644 --- a/radicale/xmlutils.py +++ b/radicale/xmlutils.py @@ -239,11 +239,10 @@ def _propfind_response(path, item, props, user): tag = ET.Element(_tag("D", "href")) tag.text = path element.append(tag) - elif tag in ( - _tag("D", "principal-collection-set"), - _tag("C", "calendar-user-address-set"), - _tag("CR", "addressbook-home-set"), - _tag("C", "calendar-home-set")): + elif tag in (_tag("D", "principal-collection-set"), + _tag("C", "calendar-user-address-set"), + _tag("CR", "addressbook-home-set"), + _tag("C", "calendar-home-set")): tag = ET.Element(_tag("D", "href")) tag.text = path element.append(tag) @@ -269,8 +268,8 @@ def _propfind_response(path, item, props, user): element.append(privilege) elif tag == _tag("D", "supported-report-set"): for report_name in ( - "principal-property-search", "sync-collection" - "expand-property", "principal-search-property-set"): + "principal-property-search", "sync-collection" + "expand-property", "principal-search-property-set"): supported = ET.Element(_tag("D", "supported-report")) report_tag = ET.Element(_tag("D", "report")) report_tag.text = report_name @@ -425,9 +424,8 @@ def report(path, xml_request, collection): props = [prop.tag for prop in prop_element] if collection: - if root.tag in ( - _tag("C", "calendar-multiget"), - _tag("CR", "addressbook-multiget")): + if root.tag in (_tag("C", "calendar-multiget"), + _tag("CR", "addressbook-multiget")): # Read rfc4791-7.9 for info hreferences = set( href_element.text for href_element @@ -485,8 +483,8 @@ def report(path, xml_request, collection): element = ET.Element(tag) if tag == _tag("D", "getetag"): element.text = item.etag - elif tag in ( - _tag("C", "calendar-data"), _tag("CR", "address-data")): + elif tag in (_tag("C", "calendar-data"), + _tag("CR", "address-data")): if isinstance(item, ical.Component): element.text = ical.serialize( collection_tag, collection_headers, From 0cf9b92ce7839ee60b498e2fe26c55227539bfc4 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Fri, 3 Aug 2012 14:37:02 +0200 Subject: [PATCH 5/6] Version 0.7.1 --- NEWS.rst | 12 ++++++++++++ radicale/__init__.py | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/NEWS.rst b/NEWS.rst index 93c9be0b..7bbc28e7 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -3,6 +3,18 @@ ====== +0.7.1 - Waterfalls +================== + +* Many address books fixes +* New IMAP ACL (by Daniel Aleksandersen) +* PAM ACL fixed (by Daniel Aleksandersen) +* Courier ACL fixed (by Benjamin Frank) +* Always set display name to collections (by Oskari Timperi) +* Various DELETE responses fixed + + + 0.7 - Eternal Sunshine ====================== diff --git a/radicale/__init__.py b/radicale/__init__.py index 28ef953a..e8757600 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -49,7 +49,7 @@ except ImportError: from radicale import acl, config, ical, log, storage, xmlutils -VERSION = "git" +VERSION = "0.7.1" class HTTPServer(wsgiref.simple_server.WSGIServer, object): From 7d06d1b4d55523fb50144b33905335e4a691ed72 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Fri, 3 Aug 2012 14:37:40 +0200 Subject: [PATCH 6/6] Version set to "git" --- radicale/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radicale/__init__.py b/radicale/__init__.py index e8757600..28ef953a 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -49,7 +49,7 @@ except ImportError: from radicale import acl, config, ical, log, storage, xmlutils -VERSION = "0.7.1" +VERSION = "git" class HTTPServer(wsgiref.simple_server.WSGIServer, object):