summaryrefslogtreecommitdiff
path: root/Mailman/database/model/user.py
diff options
context:
space:
mode:
authorBarry Warsaw2007-06-15 00:50:40 -0400
committerBarry Warsaw2007-06-15 00:50:40 -0400
commit067f871fdcaf51a0de8a1468006d3bad2e3a9a24 (patch)
tree8404972f48ad55b4a2353c2f33369fb51351e500 /Mailman/database/model/user.py
parent125f16ea72934e4dd18529a597b155c0aaca9ff6 (diff)
downloadmailman-067f871fdcaf51a0de8a1468006d3bad2e3a9a24.tar.gz
mailman-067f871fdcaf51a0de8a1468006d3bad2e3a9a24.tar.zst
mailman-067f871fdcaf51a0de8a1468006d3bad2e3a9a24.zip
Update the IUser interface and tests, specifically as it relates to
preferences. IAddresses, IUsers, and IMembers all get preferences by default, althoughthe attributes of these preferences are None by default. IMailingLists don't get preferences by default though; because these live in the user database, we can't cross-polinate them in the mailing lists. We'll figure something out later for these. IUser.register(): Add this method which registers and links an address to the user. Allow EnumType database columns to accept and return Nones. This is useful for when the columns are not defined NOT NULL. Update doctests. Removed teh hide_address preference. I can't think of a reason not to want to hide addresses for everyone.
Diffstat (limited to 'Mailman/database/model/user.py')
-rw-r--r--Mailman/database/model/user.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Mailman/database/model/user.py b/Mailman/database/model/user.py
index 45fcbfdd3..9419f181d 100644
--- a/Mailman/database/model/user.py
+++ b/Mailman/database/model/user.py
@@ -21,6 +21,7 @@ from zope.interface import implements
from Mailman import Errors
from Mailman.database.model import Address
+from Mailman.database.model import Preferences
from Mailman.interfaces import IUser
ADDRESS_KIND = 'Mailman.database.model.address.Address'
@@ -57,3 +58,17 @@ class User(Entity):
def controls(self, address):
found = Address.get_by(address=address)
return bool(found and found.user is self)
+
+ def register(self, address, real_name=None):
+ # First, see if the address already exists
+ addrobj = Address.get_by(address=address)
+ if addrobj is None:
+ if real_name is None:
+ real_name = ''
+ addrobj = Address(address=address, real_name=real_name)
+ # Link the address to the user if it is not already linked.
+ if addrobj.user is not None:
+ raise Errors.AddressAlreadyLinkedError(addrobj)
+ addrobj.user = self
+ self.addresses.append(addrobj)
+ return addrobj