示例#1
0
文件: user.py 项目: aswinpj/Mailman
 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
示例#2
0
文件: user.py 项目: inonit/mailman
 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
示例#3
0
 def create_address(self, store, email, display_name=None):
     """See `IUserManager`."""
     addresses = store.query(Address).filter(Address.email == email.lower())
     if addresses.count() == 1:
         found = addresses[0]
         raise ExistingAddressError(found.original_email)
     assert addresses.count() == 0, 'Unexpected results'
     if display_name is None:
         display_name = ''
     # It's okay not to lower case the 'email' argument because the
     # constructor will do the right thing.
     address = Address(email, display_name)
     address.preferences = Preferences()
     store.add(address)
     return address
示例#4
0
 def create_address(self, store, email, display_name=None):
     """See `IUserManager`."""
     addresses = store.query(Address).filter(Address.email == email.lower())
     if addresses.count() == 1:
         found = addresses[0]
         raise ExistingAddressError(found.original_email)
     assert addresses.count() == 0, 'Unexpected results'
     if display_name is None:
         display_name = ''
     # It's okay not to lower case the 'email' argument because the
     # constructor will do the right thing.
     address = Address(email, display_name)
     address.preferences = Preferences()
     store.add(address)
     return address
示例#5
0
 def test_invalid_email_string_raises_exception(self):
     with self.assertRaises(InvalidEmailAddressError):
         Address('not_a_valid_email_string', '')