Esempio 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
Esempio n. 2
0
 def register(self, store, email, display_name=None):
     """See `IUser`."""
     # First, see if the address already exists
     address = store.query(Address).filter_by(email=email).first()
     if address is None:
         if display_name is None:
             display_name = ''
         address = Address(email=email, display_name=display_name)
         address.preferences = Preferences()
     # Link the address to the user if it is not already linked.
     if address.user is not None:
         raise AddressAlreadyLinkedError(address)
     address.user = self
     return address
Esempio n. 3
0
 def link(self, address):
     """See `IUser`."""
     if address.user is not None:
         raise AddressAlreadyLinkedError(address)
     address.user = self