From: Tony Mack Date: Thu, 14 Jun 2007 16:26:23 +0000 (+0000) Subject: - updated with Thierrys patch which handles conflicting email addresses between peers X-Git-Tag: PLCAPI-4.2-0~118 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=32a7859efc899b826dc5d7a7cde4f7e0606e09ee;p=plcapi.git - updated with Thierrys patch which handles conflicting email addresses between peers --- diff --git a/PLC/Methods/RefreshPeer.py b/PLC/Methods/RefreshPeer.py index 5332074..6c0444f 100644 --- a/PLC/Methods/RefreshPeer.py +++ b/PLC/Methods/RefreshPeer.py @@ -1,7 +1,7 @@ # # Thierry Parmentelat - INRIA # -# $Id$ +# $Id: RefreshPeer.py,v 1.23 2007/03/23 19:05:16 thierry Exp $ import time @@ -228,6 +228,11 @@ class RefreshPeer(Method): # Keyed on foreign person_id old_peer_persons = Persons(self.api, {'peer_id': peer_id}, columns).dict('peer_person_id') + + # artificially attach the persons returned by GetPeerData to the new peer + # this is because validate_email needs peer_id to be correct when checking for duplicates + for person in peer_tables['Persons']: + person['peer_id']=peer_id persons_at_peer = dict([(peer_person['person_id'], peer_person) \ for peer_person in peer_tables['Persons']]) diff --git a/PLC/Persons.py b/PLC/Persons.py index 6da08ec..32549cf 100644 --- a/PLC/Persons.py +++ b/PLC/Persons.py @@ -4,7 +4,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: Persons.py,v 1.35 2007/03/29 13:17:09 tmack Exp $ +# $Id: Persons.py,v 1.36 2007/03/29 20:14:46 tmack Exp $ # from types import StringTypes @@ -100,8 +100,15 @@ class Person(Row): if len(domain) < 2: raise invalid_email - conflicts = Persons(self.api, [email]) - for person in conflicts: + # check only against users on the same peer + if 'peer_id' in self: + namespace_peer_id = self['peer_id'] + else: + namespace_peer_id = None + + conflicts = Persons(self.api, {'email':email,'peer_id':namespace_peer_id}) + + for person in conflicts: if 'person_id' not in self or self['person_id'] != person['person_id']: raise PLCInvalidArgument, "E-mail address already in use"