caldav: don't bork if client requests foobar.ics
authorP. Christeas <p_christ@hol.gr>
Thu, 12 Aug 2010 11:10:18 +0000 (14:10 +0300)
committerP. Christeas <p_christ@hol.gr>
Thu, 12 Aug 2010 11:10:18 +0000 (14:10 +0300)
bzr revid: p_christ@hol.gr-20100812111018-tzpw0yixyuwp4dg0

addons/caldav/caldav_node.py

index 5ebe38c..700caaf 100644 (file)
@@ -86,11 +86,11 @@ class node_calendar_collection(nodes.node_dir):
                 res.append(node_calendar(cal.name, self, self.context, cal))
             if (not name) or ext:
                 res.append(res_node_calendar(cal.name+'.ics', self, self.context, cal))
-           # May be both of them!
+            # May be both of them!
         return res
 
     def _get_dav_owner(self, cr):
-       # Todo?
+        # Todo?
         return False
 
     def _get_ttag(self, cr):
@@ -206,7 +206,15 @@ class node_calendar(nodes.node_class):
         if name:
             if name.endswith('.ics'):
                 name = name[:-4]
-            where.append(('id','=',int(name)))
+            try:
+                where.append(('id','=',int(name)))
+            except ValueError:
+                # if somebody requests any other name than the ones we
+                # generate (non-numeric), it just won't exist
+                # FIXME: however, this confuses Evolution (at least), which
+                # thinks the .ics node hadn't been saved.
+                return []
+
         if not domain:
             domain = []
         #for opr1, opt, opr2 in domain: