# HG changeset patch # User Paul Boddie # Date 1441209211 -7200 # Node ID de3256d930d54ca8593a57ff852b22519b441e52 # Parent eb9cb0939b037075fbea556d8f94ebe3c053d751 Added tentative support for the ADD method, which is arguably best ignored in favour of REFRESH method usage. diff -r eb9cb0939b03 -r de3256d930d5 imiptools/client.py --- a/imiptools/client.py Wed Sep 02 17:52:52 2015 +0200 +++ b/imiptools/client.py Wed Sep 02 17:53:31 2015 +0200 @@ -266,13 +266,24 @@ # Object update methods. + def update_recurrenceid(self): + + """ + Update the RECURRENCE-ID in the current object, initialising it from + DTSTART. + """ + + self.obj["RECURRENCE-ID"] = [self.obj.get_datetime_item("DTSTART")] + self.recurrenceid = self.obj.get_recurrenceid() + def update_dtstamp(self): "Update the DTSTAMP in the current object." dtstamp = self.obj.get_utc_datetime("DTSTAMP") utcnow = to_timezone(datetime.utcnow(), "UTC") - self.obj["DTSTAMP"] = [(format_datetime(dtstamp > utcnow and dtstamp or utcnow), {})] + self.dtstamp = format_datetime(dtstamp > utcnow and dtstamp or utcnow) + self.obj["DTSTAMP"] = [(self.dtstamp, {})] def set_sequence(self, increment=False): @@ -535,7 +546,8 @@ Update the 'freebusy' collection for this event with the periods and transparency associated with the current object, subject to the 'user' identity and the attendance details provided for them, indicating - whether the update is 'for_organiser' or not. + whether the update is being done 'for_organiser' (for the organiser of + an event) or not. """ # Obtain the stored object if the current object is not issued by the @@ -569,14 +581,14 @@ """ Update the 'freebusy' collection using the given 'periods', involving - the given 'user', indicating whether the update is 'for_organiser' or - not, and whether it is 'updating_other' (meaning another user's - details). + the given 'user', indicating whether the update is 'for_organiser' + (being done for the organiser of an event) or not, and whether it is + 'updating_other' (meaning another user's details). """ # Record in the free/busy details unless a non-participating attendee. - # Use any attendee information for an organiser, not the organiser's own - # attributes. + # Use any attendee property information for an organiser, not the + # organiser property attributes. if self.is_participating(user, for_organiser and not updating_other): self.update_freebusy(freebusy, user, for_organiser) diff -r eb9cb0939b03 -r de3256d930d5 imiptools/handlers/common.py --- a/imiptools/handlers/common.py Wed Sep 02 17:52:52 2015 +0200 +++ b/imiptools/handlers/common.py Wed Sep 02 17:53:31 2015 +0200 @@ -70,15 +70,18 @@ "Common outgoing message handling functionality mix-in." - def update_event_in_freebusy(self, from_organiser=True): + def update_event_in_freebusy(self, for_organiser=True): - "Update free/busy information when handling an object." + """ + Update free/busy information when handling an object, doing so for the + organiser of an event if 'for_organiser' is set to a true value. + """ freebusy = self.store.get_freebusy(self.user) # Obtain the attendance attributes for this user, if available. - self.update_freebusy_for_participant(freebusy, self.user, from_organiser) + self.update_freebusy_for_participant(freebusy, self.user, for_organiser) # Remove original recurrence details replaced by additional # recurrences, as well as obsolete additional recurrences. diff -r eb9cb0939b03 -r de3256d930d5 imiptools/handlers/resource.py --- a/imiptools/handlers/resource.py Wed Sep 02 17:52:52 2015 +0200 +++ b/imiptools/handlers/resource.py Wed Sep 02 17:53:31 2015 +0200 @@ -51,12 +51,33 @@ handle_for_attendee() - def _schedule_for_attendee(self): + def _add_for_attendee(self): """ - Attempt to schedule the current object for the current user. + Attempt to add a recurrence to an existing object for the current user. + This does not request a response concerning participation, apparently. """ + # Ignore unknown objects. + # NOTE: We could issue a REFRESH to get such objects. + + if not self.get_stored_object_version(): + return + + # Record the event as a recurrence of the parent object. + + self.update_recurrenceid() + event = self.obj.to_node() + self.store.set_event(self.user, self.uid, self.recurrenceid, event) + + # Update free/busy information. + + self.update_event_in_freebusy(for_organiser=False) + + def _schedule_for_attendee(self): + + "Attempt to schedule the current object for the current user." + method = "REPLY" # Check any constraints on the request. @@ -124,7 +145,7 @@ # Update free/busy information. - self.update_event_in_freebusy(from_organiser=False) + self.update_event_in_freebusy(for_organiser=False) else: attendee_attr = self.obj.get_value_map("ATTENDEE")[self.user] @@ -156,7 +177,10 @@ "An event handler." def add(self): - pass + + "Add a new occurrence to an existing event." + + self._record_and_respond(self._add_for_attendee) def cancel(self): @@ -180,6 +204,12 @@ pass def publish(self): + + """ + Resources only consider events sent as requests, not generally published + events. + """ + pass def refresh(self): @@ -189,6 +219,8 @@ do not act as organisers themselves. """ + pass + def reply(self): "Since this handler does not send requests, it will not handle replies." @@ -211,6 +243,9 @@ "A free/busy handler." def publish(self): + + "Resources ignore generally published free/busy information." + pass def reply(self):