Guillaume Ayoub 13 лет назад
Родитель
Сommit
a17ad1b6a3
8 измененных файлов с 35 добавлено и 51 удалено
  1. 0 17
      .project
  2. 0 10
      .pydevproject
  3. 1 1
      .pylintrc
  4. 0 4
      .settings/org.eclipse.core.resources.prefs
  5. 1 1
      radicale/acl/PAM.py
  6. 1 1
      radicale/acl/courier.py
  7. 8 6
      radicale/config.py
  8. 24 11
      radicale/xmlutils.py

+ 0 - 17
.project

@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-	<name>Radicale</name>
-	<comment></comment>
-	<projects>
-	</projects>
-	<buildSpec>
-		<buildCommand>
-			<name>org.python.pydev.PyDevBuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-	</buildSpec>
-	<natures>
-		<nature>org.python.pydev.pythonNature</nature>
-	</natures>
-</projectDescription>

+ 0 - 10
.pydevproject

@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?eclipse-pydev version="1.0"?>
-
-<pydev_project>
-<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
-<path>/Radicale</path>
-</pydev_pathproperty>
-<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
-<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
-</pydev_project>

+ 1 - 1
.pylintrc

@@ -89,7 +89,7 @@ generated-members=
 [FORMAT]
 
 # Maximum number of characters on a single line.
-max-line-length=80
+max-line-length=79
 
 # Maximum number of lines in a module
 max-module-lines=1000

+ 0 - 4
.settings/org.eclipse.core.resources.prefs

@@ -1,4 +0,0 @@
-#Sat Aug 04 10:58:22 CEST 2012
-eclipse.preferences.version=1
-encoding//radicale/__init__.py=utf-8
-encoding//radicale/__main__.py=utf-8

+ 1 - 1
radicale/acl/PAM.py

@@ -47,7 +47,7 @@ def is_authenticated(user, password):
 
     # Check whether the group exists
     try:
-        members = grp.getgrnam(GROUP_MEMBERSHIP)
+        members = grp.getgrnam(GROUP_MEMBERSHIP).gr_mem
     except KeyError:
         log.LOGGER.debug(
             "The PAM membership required group (%s) doesn't exist" %

+ 1 - 1
radicale/acl/courier.py

@@ -51,7 +51,7 @@ def is_authenticated(user, password):
     # Address, HOME, GID, and either UID or USERNAME are mandatory in resposne
     # see http://www.courier-mta.org/authlib/README_authlib.html#authpipeproto
     for line in data.split():
-        if 'GID' in line:
+        if "GID" in line:
             return True
 
     # default is reject

+ 8 - 6
radicale/config.py

@@ -53,8 +53,10 @@ INITIAL_CONFIG = {
         "type": "None",
         "public_users": "public",
         "private_users": "private",
-        "httpasswd_filename": "/etc/radicale/users",
-        "httpasswd_encryption": "crypt",
+        "htpasswd_filename": "/etc/radicale/users",
+        "htpasswd_encryption": "crypt",
+        "imap_auth_host_name": "localhost",
+        "imap_auth_host_port": "143",
         "ldap_url": "ldap://localhost:389/",
         "ldap_base": "ou=users,dc=example,dc=com",
         "ldap_attribute": "uid",
@@ -66,10 +68,10 @@ INITIAL_CONFIG = {
         "courier_socket": ""},
     "storage": {
         "type": "filesystem",
-        "filesystem_folder":
-            os.path.expanduser("~/.config/radicale/collections"),
-        "git_folder":
-            os.path.expanduser("~/.config/radicale/collections")},
+        "filesystem_folder": os.path.expanduser(
+            "~/.config/radicale/collections"),
+        "git_folder": os.path.expanduser(
+            "~/.config/radicale/collections")},
     "logging": {
         "config": "/etc/radicale/logging",
         "debug": "False",

+ 24 - 11
radicale/xmlutils.py

@@ -240,11 +240,10 @@ def _propfind_response(path, item, props, user):
             tag = ET.Element(_tag("D", "href"))
             tag.text = path
             element.append(tag)
-        elif tag in (
-            _tag("D", "principal-collection-set"),
-            _tag("C", "calendar-user-address-set"),
-            _tag("CR", "addressbook-home-set"),
-            _tag("C", "calendar-home-set")):
+        elif tag in (_tag("D", "principal-collection-set"),
+                     _tag("C", "calendar-user-address-set"),
+                     _tag("CR", "addressbook-home-set"),
+                     _tag("C", "calendar-home-set")):
             tag = ET.Element(_tag("D", "href"))
             tag.text = path
             element.append(tag)
@@ -284,12 +283,14 @@ def _propfind_response(path, item, props, user):
                 if item.is_principal:
                     tag = ET.Element(_tag("D", "principal"))
                     element.append(tag)
-                if item.is_leaf(item.path):
-                    tag = ET.Element(_tag("C", item.resource_type))
-                    element.append(tag)
-                if not item.exists and item.resource_type:
-                    # Collection not stored yet, but guessed resource type
-                    tag = ET.Element(_tag("C", item.resource_type))
+                if item.is_leaf(item.path) or (
+                        not item.exists and item.resource_type):
+                    # 2nd case happens when the collection is not stored yet,
+                    # but the resource type is guessed
+                    if item.resource_type == "addressbook":
+                        tag = ET.Element(_tag("CR", item.resource_type))
+                    else:
+                        tag = ET.Element(_tag("C", item.resource_type))
                     element.append(tag)
                 tag = ET.Element(_tag("D", "collection"))
                 element.append(tag)
@@ -300,6 +301,8 @@ def _propfind_response(path, item, props, user):
             elif tag == _tag("C", "calendar-timezone"):
                 element.text = ical.serialize(
                     item.tag, item.headers, item.timezones)
+            elif tag == _tag("D", "displayname"):
+                element.text = item.name
             else:
                 human_tag = _tag_from_clark(tag)
                 if human_tag in collection_props:
@@ -430,8 +433,15 @@ def report(path, xml_request, collection):
                 in root.findall(_tag("D", "href")))
         else:
             hreferences = (path,)
+        # TODO: handle other filters
+        # TODO: handle the nested comp-filters correctly
+        # Read rfc4791-9.7.1 for info
+        tag_filters = set(
+            element.get("name") for element
+            in root.findall(".//%s" % _tag("C", "comp-filter")))
     else:
         hreferences = ()
+        tag_filters = None
 
     # Writing answer
     multistatus = ET.Element(_tag("D", "multistatus"))
@@ -454,6 +464,9 @@ def report(path, xml_request, collection):
             items = collection.components
 
         for item in items:
+            if tag_filters and item.tag not in tag_filters:
+                continue
+
             response = ET.Element(_tag("D", "response"))
             multistatus.append(response)