imip-agent

Change of imip_store.py

378:7e3930192655
imip_store.py recurring-events
     1.1 --- a/imip_store.py	Wed Mar 04 17:13:56 2015 +0100
     1.2 +++ b/imip_store.py	Wed Mar 04 18:03:35 2015 +0100
     1.3 @@ -234,9 +234,7 @@
     1.4  
     1.5          "Remove an event for 'user' having the given 'uid'."
     1.6  
     1.7 -        recurrences = self.get_object_in_store(user, "recurrences", uid)
     1.8 -        if recurrences:
     1.9 -            self._remove_collection(recurrences)
    1.10 +        self.remove_recurrences(user, uid)
    1.11  
    1.12          filename = self.get_object_in_store(user, "objects", uid)
    1.13          if not filename:
    1.14 @@ -282,14 +280,33 @@
    1.15  
    1.16      def remove_recurrence(self, user, uid, recurrenceid):
    1.17  
    1.18 -        "Remove an event for 'user' having the given 'uid'."
    1.19 +        """
    1.20 +        Remove a special recurrence from an event stored by 'user' having the
    1.21 +        given 'uid' and 'recurrenceid'.
    1.22 +        """
    1.23  
    1.24 -        filename = self.get_object_in_store(user, "recurrences", uid)
    1.25 +        filename = self.get_object_in_store(user, "recurrences", uid, recurrenceid)
    1.26          if not filename:
    1.27              return False
    1.28  
    1.29          return self._remove_object(filename)
    1.30  
    1.31 +    def remove_recurrences(self, user, uid):
    1.32 +
    1.33 +        """
    1.34 +        Remove all recurrences for an event stored by 'user' having the given
    1.35 +        'uid'.
    1.36 +        """
    1.37 +
    1.38 +        for recurrenceid in self.get_recurrences(user, uid):
    1.39 +            self.remove_recurrence(user, uid, recurrenceid)
    1.40 +
    1.41 +        recurrences = self.get_object_in_store(user, "recurrences", uid)
    1.42 +        if recurrences:
    1.43 +            return self._remove_collection(recurrences)
    1.44 +
    1.45 +        return True
    1.46 +
    1.47      def get_freebusy(self, user):
    1.48  
    1.49          "Get free/busy details for the given 'user'."