Add support for the Caldav-Sync Android client

This commit is contained in:
Marten Gajda 2011-07-14 11:04:41 +02:00 committed by Guillaume Ayoub
parent 3356d3235f
commit 380acebd71
2 changed files with 14 additions and 3 deletions

View File

@ -39,11 +39,11 @@ import wsgiref.simple_server
# pylint: disable=F0401 # pylint: disable=F0401
try: try:
from http import client, server from http import client, server
from urllib.parse import unquote, urlparse from urllib.parse import quote, unquote, urlparse
except ImportError: except ImportError:
import httplib as client import httplib as client
import BaseHTTPServer as server import BaseHTTPServer as server
from urllib import unquote from urllib import quote, unquote
from urlparse import urlparse from urlparse import urlparse
# pylint: enable=F0401 # pylint: enable=F0401
@ -221,6 +221,14 @@ class Application(object):
if calendars: if calendars:
status, headers, answer = function( status, headers, answer = function(
environ, calendars, content, user) environ, calendars, content, user)
elif user and self.acl.has_right(user, user, password):
# Check if the user/password couple matches,
# redirect user to his principal home in this case
location = "/%s/" % str(quote(user))
log.LOGGER.info("redirecting to %s" % location)
status = client.FOUND
headers = {"Location": location}
answer = "Redirecting to %s" % location
else: else:
status = client.UNAUTHORIZED status = client.UNAUTHORIZED
headers = { headers = {

View File

@ -171,7 +171,10 @@ class Calendar(object):
""" """
self.encoding = "utf-8" self.encoding = "utf-8"
split_path = path.split("/") split_path = path.split("/")
self.owner = split_path[0] if len(split_path) > 1 else None if (principal and split_path) or len(split_path) > 1:
self.owner = split_path[0]
else:
self.owner = None
self.path = os.path.join(FOLDER, path.replace("/", os.sep)) self.path = os.path.join(FOLDER, path.replace("/", os.sep))
self.local_path = path if path != '.' else '' self.local_path = path if path != '.' else ''
self.is_principal = principal self.is_principal = principal