# HG changeset patch # User Paul Boddie # Date 1442617660 -7200 # Node ID 02fb76c41c87cca07597eea0b49b16d586d33044 # Parent 11ecf9db1d267e53b8be12196af1b824bcdab063 Added support for obtaining counter-proposals and for testing the presence of requests either for an object in general or having a specific request type. diff -r 11ecf9db1d26 -r 02fb76c41c87 imip_store.py --- a/imip_store.py Sat Sep 19 00:11:13 2015 +0200 +++ b/imip_store.py Sat Sep 19 01:07:40 2015 +0200 @@ -741,12 +741,33 @@ self.set_requests(user, result) return True - def have_request(self, requests, uid, recurrenceid=None): + def have_request(self, requests, uid, recurrenceid=None, type=None, strict=False): + + """ + Return whether 'requests' contains a request with the given 'uid' and + any specified 'recurrenceid' and 'type'. If 'strict' is set to a true + value, the precise type of the request must match; otherwise, any type + of request for the identified object may be matched. + """ + for request in requests: if request[:2] == (uid, recurrenceid): return True return False + def get_counter(self, user, uid, recurrenceid=None): + + """ + For the given 'user', return the counter-proposal for the given 'uid' + and optional 'recurrenceid'. + """ + + filename = self.get_event_filename(user, uid, recurrenceid, "counters") + if not filename: + return False + + return filename and self._get_object(user, filename) + def set_counter(self, user, node, uid, recurrenceid=None): """