Exemplo n.º 1
0
 def preferred_address(self, address):
     """See `IUser`."""
     if address.verified_on is None:
         raise UnverifiedAddressError(address)
     if self.controls(address.email):
         # This user already controls the email address.
         pass
     elif address.user is None:
         self.link(address)
     elif address.user != self:
         raise AddressAlreadyLinkedError(address)
     self._preferred_address = address
Exemplo n.º 2
0
 def address(self, new_address):
     """See `IMember`."""
     if self._address is None:
         # XXX Either we need a better exception here, or we should allow
         # changing a subscription from preferred address to explicit
         # address (and vice versa via del'ing the .address attribute.
         raise MembershipError('Membership is via preferred address')
     if new_address.verified_on is None:
         # A member cannot change their subscription address to an
         # unverified address.
         raise UnverifiedAddressError('Unverified address')
     user = getUtility(IUserManager).get_user(new_address.email)
     if user is None or user != self.user:
         raise MembershipError('Address is not controlled by user')
     self._address = new_address