1.1 --- a/imiptools/client.py Sat Sep 12 18:15:26 2015 +0200
1.2 +++ b/imiptools/client.py Sat Sep 12 19:58:59 2015 +0200
1.3 @@ -37,6 +37,7 @@
1.4 "Common handler and manager methods."
1.5
1.6 default_window_size = 100
1.7 + organiser_methods = "ADD", "CANCEL", "DECLINECOUNTER", "PUBLISH", "REQUEST"
1.8
1.9 def __init__(self, user, messenger=None, store=None, publisher=None, preferences_dir=None):
1.10
1.11 @@ -279,6 +280,17 @@
1.12 self.sequence = obj and self.obj.get_value("SEQUENCE")
1.13 self.dtstamp = obj and self.obj.get_value("DTSTAMP")
1.14
1.15 + def set_identity(self, method):
1.16 +
1.17 + """
1.18 + Set the current user for the current object in the context of the given
1.19 + 'method'. It is usually set when initialising the handler, using the
1.20 + recipient details, but outgoing messages do not reference the recipient
1.21 + in this way.
1.22 + """
1.23 +
1.24 + pass
1.25 +
1.26 def is_usable(self, method=None):
1.27
1.28 "Return whether the current object is usable with the given 'method'."
2.1 --- a/imiptools/content.py Sat Sep 12 18:15:26 2015 +0200
2.2 +++ b/imiptools/content.py Sat Sep 12 19:58:59 2015 +0200
2.3 @@ -69,6 +69,8 @@
2.4 # Dispatch to a handler and obtain any response.
2.5
2.6 handler.set_object(Object({name : item}))
2.7 + handler.set_identity(method)
2.8 +
2.9 if handler.is_usable(method):
2.10 methods[method](handler)()
2.11
3.1 --- a/imiptools/handlers/person_outgoing.py Sat Sep 12 18:15:26 2015 +0200
3.2 +++ b/imiptools/handlers/person_outgoing.py Sat Sep 12 19:58:59 2015 +0200
3.3 @@ -21,7 +21,7 @@
3.4 """
3.5
3.6 from imiptools.client import Client
3.7 -from imiptools.data import uri_dict, uri_item, uri_values
3.8 +from imiptools.data import get_uri, uri_dict, uri_values
3.9 from imiptools.handlers import Handler
3.10 from imiptools.handlers.common import CommonEvent
3.11
3.12 @@ -29,21 +29,23 @@
3.13
3.14 "Handling mechanisms specific to people."
3.15
3.16 - def set_identity(self, from_organiser=True):
3.17 + def set_identity(self, method):
3.18
3.19 """
3.20 - Set the current user for the current object. It is usually set when
3.21 - initialising the handler, using the recipient details, but outgoing
3.22 - messages do not reference the recipient in this way.
3.23 + Set the current user for the current object in the context of the given
3.24 + 'method'. It is usually set when initialising the handler, using the
3.25 + recipient details, but outgoing messages do not reference the recipient
3.26 + in this way.
3.27 """
3.28
3.29 - self.user, attr = uri_item(self.obj.get_item(from_organiser and "ORGANIZER" or "ATTENDEE"))
3.30 + if self.obj:
3.31 + from_organiser = method in self.organiser_methods
3.32 + self.user = get_uri(self.obj.get_value(from_organiser and "ORGANIZER" or "ATTENDEE"))
3.33
3.34 def _add(self):
3.35
3.36 "Add a recurrence for the current object."
3.37
3.38 - self.set_identity()
3.39 if not Client.is_participating(self):
3.40 return False
3.41
3.42 @@ -81,7 +83,6 @@
3.43 from an organiser if 'from_organiser' is set to a true value.
3.44 """
3.45
3.46 - self.set_identity(from_organiser)
3.47 if not Client.is_participating(self):
3.48 return False
3.49
3.50 @@ -128,7 +129,6 @@
3.51 from an organiser if 'from_organiser' is set to a true value.
3.52 """
3.53
3.54 - self.set_identity(True)
3.55 if not Client.is_participating(self):
3.56 return False
3.57