# HG changeset patch # User Sverre Rabbelier # Date 1235667323 0 # Node ID 983b126f5aca353bd657553d2970f697ca3014cb # Parent bb086732bf7f803b73a833c3e60889d6395cf886 Always normalize accounts, before even storing them Patch by: Sverre Rabbelier diff -r bb086732bf7f -r 983b126f5aca app/soc/logic/cleaning.py --- a/app/soc/logic/cleaning.py Thu Feb 26 16:54:44 2009 +0000 +++ b/app/soc/logic/cleaning.py Thu Feb 26 16:55:23 2009 +0000 @@ -222,12 +222,9 @@ @check_field_is_empty(field_name) def wrapped(self): - email_adress = self.cleaned_data.get(field_name).lower() + email_adress = self.cleaned_data[field_name] + return users.User(email_adress) - # get the user account for this email - user_account = users.User(email_adress) - - return user_account return wrapped diff -r bb086732bf7f -r 983b126f5aca app/soc/logic/models/user.py --- a/app/soc/logic/models/user.py Thu Feb 26 16:54:44 2009 +0000 +++ b/app/soc/logic/models/user.py Thu Feb 26 16:55:23 2009 +0000 @@ -146,6 +146,17 @@ return ['link_id'] + def _createField(self, entity_properties, name): + """Normalize the account before storing it. + """ + + value = entity_properties[name] + + if (name == 'account'): + # normalize all accounts before doing anything with the value + value = accounts.normalizeAccount(value) + entity_properties[name] = value + def _updateField(self, entity, entity_properties, name): """Special case logic for account. @@ -174,15 +185,12 @@ sidebar.flush(entity.account) if (name == 'account'): - if (str(entity.account) != str(value)): + # normalize all accounts before doing anything with the value + value = accounts.normalizeAccount(value) + entity_properties[name] = value + + if entity.account != value: entity.former_accounts.append(entity.account) - elif entity.account != value: - # this occurs when the account ends in the auth domain, e.g.: - # if the auth domain is "example.com", then the following would - # would put us here: - # entity.account = users.User('foo@example.com') - # value = 'foo' - return False return True