diff --git a/radicale/__init__.py b/radicale/__init__.py index 4115852..a588aa7 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -430,7 +430,7 @@ class Application(object): # TODO: use this? # timezone = props.get("C:calendar-timezone") collection = storage.Collection.create_collection( - collection.path, tag="VCALENDAR") + environ["PATH_INFO"], tag="VCALENDAR") for key, value in props.items(): collection.set_meta(key, value) return client.CREATED, {}, None @@ -444,7 +444,7 @@ class Application(object): collection = write_collections[0] props = xmlutils.props_from_request(content) - collection = storage.Collection.create_collection(collection.path) + collection = storage.Collection.create_collection(environ["PATH_INFO"]) for key, value in props.items(): collection.set_meta(key, value) return client.CREATED, {}, None diff --git a/radicale/storage.py b/radicale/storage.py index 04106c9..81ba592 100644 --- a/radicale/storage.py +++ b/radicale/storage.py @@ -175,8 +175,15 @@ class Collection: return # Try to guess if the path leads to a collection or an item - if os.path.isfile(path_to_filesystem(FOLDER, sane_path)): - attributes.pop() + if not os.path.isdir(path_to_filesystem(FOLDER, sane_path)): + # path is not a collection + if os.path.isfile(path_to_filesystem(FOLDER, sane_path)): + # path is an item + attributes.pop() + elif os.path.isdir(path_to_filesystem(FOLDER, *attributes[:-1])): + # path parent is a collection + attributes.pop() + # TODO: else: return? path = "/".join(attributes)