Merge branch 'master' of git://gitorious.org/radicale/radicale

This commit is contained in:
Corentin Le Bail 2011-04-10 19:17:51 +02:00
commit c34d5cd7cd
3 changed files with 9 additions and 3 deletions

View File

@ -56,6 +56,10 @@ def _sha1(hash_value, password):
def has_right(owner, user, password): def has_right(owner, user, password):
"""Check if ``user``/``password`` couple is valid.""" """Check if ``user``/``password`` couple is valid."""
if owner is None and PERSONAL:
# No owner and personal calendars, everybody is allowed
return True
for line in open(FILENAME).readlines(): for line in open(FILENAME).readlines():
if line.strip(): if line.strip():
login, hash_value = line.strip().split(":") login, hash_value = line.strip().split(":")

View File

@ -136,7 +136,8 @@ class Calendar(object):
def __init__(self, path): def __init__(self, path):
"""Initialize the calendar with ``cal`` and ``user`` parameters.""" """Initialize the calendar with ``cal`` and ``user`` parameters."""
self.encoding = "utf-8" self.encoding = "utf-8"
self.owner = path.split("/")[0] split_path = path.split("/")
self.owner = split_path[0] if len(split_path) > 1 else None
self.path = os.path.join(FOLDER, path.replace("/", os.path.sep)) self.path = os.path.join(FOLDER, path.replace("/", os.path.sep))
@staticmethod @staticmethod

View File

@ -53,7 +53,7 @@ def name_from_path(path):
"""Return Radicale item name from ``path``.""" """Return Radicale item name from ``path``."""
log.log(10, "Return Radicale item name from ``path``.") log.log(10, "Return Radicale item name from ``path``.")
path_parts = path.strip("/").split("/") path_parts = path.strip("/").split("/")
return path_parts[-1] if len(path_parts) > 2 else None return path_parts[-1] if len(path_parts) >= 2 else None
def delete(path, calendar): def delete(path, calendar):
@ -133,7 +133,8 @@ def propfind(path, xml_request, calendar, depth):
tag = ET.Element(_tag("D", "collection")) tag = ET.Element(_tag("D", "collection"))
element.append(tag) element.append(tag)
elif tag == _tag("D", "owner"): elif tag == _tag("D", "owner"):
element.text = calendar.owner if calendar.owner:
element.text = calendar.owner
elif tag == _tag("D", "getcontenttype"): elif tag == _tag("D", "getcontenttype"):
element.text = "text/calendar" element.text = "text/calendar"
elif tag == _tag("CS", "getctag") and is_calendar: elif tag == _tag("CS", "getctag") and is_calendar: