From e33ee8ea7ce279540df73501a3647fc09efc8d0f Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Wed, 8 Aug 2012 18:54:58 +0200 Subject: [PATCH] Small fixes --- radicale/__init__.py | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/radicale/__init__.py b/radicale/__init__.py index 3683f4d..3e9802b 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -214,22 +214,28 @@ class Application(object): last_collection_allowed = None allowed_items = [] for item in items: - log.LOGGER.debug("Testing %s" % (item.name)) - if not isinstance(item, ical.Collection): + if isinstance(item, ical.Collection): + if access.read_authorized(user, item) or \ + access.write_authorized(user, item): + log.LOGGER.info("%s has access to collection %s" % ( + user, item.name or "/")) + last_collection_allowed = True + allowed_items.append(item) + else: + log.LOGGER.info("%s has NO access to collection %s" % ( + user, item.name or "/")) + last_collection_allowed = False + else: # 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) - else: - if access.read_authorized(user, item) or \ - access.write_authorized(user, item): - log.LOGGER.info("%s has access to %s" % ( - user, item.name)) - last_collection_allowed = True + log.LOGGER.info("%s has access to item %s" % ( + user, item.name or "/")) allowed_items.append(item) else: - last_collection_allowed = False + log.LOGGER.info("%s has NO access to item %s" % ( + user, item.name or "/")) if allowed_items: # Collections found @@ -319,7 +325,7 @@ class Application(object): # Display a "Radicale works!" message if the root URL is requested if environ["PATH_INFO"] == "/": headers = {"Content-type": "text/html"} - answer = "\nRadicaleRadicale works!" + answer = b"\nRadicaleRadicale works!" return client.OK, headers, answer collection = collections[0] @@ -341,8 +347,9 @@ class Application(object): return client.GONE, {}, None else: # Create the collection if it does not exist - if not collection.exists and access.write_authorized(user, collection): - log.LOGGER.debug("creating collection " + collection.name) + if not collection.exists and \ + access.write_authorized(user, collection): + log.LOGGER.debug("Creating collection %s" % collection.name) collection.write() if access.read_authorized(user, collection):