From 316b0a58324e87c53dc1efa977c70912858b141b Mon Sep 17 00:00:00 2001 From: Unrud Date: Sat, 22 Jul 2017 21:41:39 +0200 Subject: [PATCH] Change owner and is_principal to properties in BaseCollection --- radicale/storage.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/radicale/storage.py b/radicale/storage.py index f19bee0..a2a6a1c 100644 --- a/radicale/storage.py +++ b/radicale/storage.py @@ -414,10 +414,26 @@ class BaseCollection: """The sanitized path of the collection without leading or trailing ``/``. """ path = "" - """The owner of the collection. (``path.split("/", maxsplit=1)[0]``)""" - owner = "" - """Collection is a principal. (``bool(path) and "/" not in path``)""" - is_principal = False + + @property + def owner(self): + """The owner of the collection.""" + return self.path.split("/", maxsplit=1)[0] + + @property + def is_principal(self): + """Collection is a principal.""" + return bool(self.path) and "/" not in self.path + + @owner.setter + def owner(self, value): + # DEPRECATED: Included for compatibility reasons + pass + + @is_principal.setter + def is_principal(self, value): + # DEPRECATED: Included for compatibility reasons + pass @classmethod def discover(cls, path, depth="0"): @@ -706,10 +722,6 @@ class Collection(BaseCollection): self._filesystem_path = path_to_filesystem(folder, self.path) self._props_path = os.path.join( self._filesystem_path, ".Radicale.props") - self.owner = self.path.split("/", maxsplit=1)[0] - if principal is None: - principal = bool(self.path) and "/" not in self.path - self.is_principal = principal self._meta_cache = None self._etag_cache = None if self._item_cache_tag is None: