summaryrefslogtreecommitdiff
path: root/Mailman/database/usermanager.py
diff options
context:
space:
mode:
authorBarry Warsaw2007-07-01 11:51:09 -0400
committerBarry Warsaw2007-07-01 11:51:09 -0400
commit0d2733eb508a91a826156f627f78253c9f7cd567 (patch)
tree94967189f2d9be9496915814f45deb9712be038e /Mailman/database/usermanager.py
parentf2ce3bc944d813d255e562a2102541fd0e24f1c0 (diff)
downloadmailman-0d2733eb508a91a826156f627f78253c9f7cd567.tar.gz
mailman-0d2733eb508a91a826156f627f78253c9f7cd567.tar.zst
mailman-0d2733eb508a91a826156f627f78253c9f7cd567.zip
Support for case-preserving addresses. When an Address is given an email
address that is not lower cased, the original, case-preserved version is store on the '_original' attribute. The lower-cased version is always used as the key and thus always stored on the 'address' attribute. The IAddress interface is given a new 'original_address' property which returns the case-preserved version. Address's __str__() and __repr__() are similarly modified. The former always includes the case-preserved address; the latter does too, but now also includes the lower-cased 'key' email address (along with the object's id). Searching for an address always does so on the lower-cased version. Test suite is updated as necessary. Also, I'm adding the REPORT_ONLY_FIRST_FAILURE doctest flag so that it's easier to debug doctest failures without having pages of problems to scroll through.
Diffstat (limited to 'Mailman/database/usermanager.py')
-rw-r--r--Mailman/database/usermanager.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/Mailman/database/usermanager.py b/Mailman/database/usermanager.py
index a37dcf60a..038427879 100644
--- a/Mailman/database/usermanager.py
+++ b/Mailman/database/usermanager.py
@@ -39,7 +39,7 @@ class UserManager(object):
user = User()
user.real_name = (real_name if real_name is not None else '')
if address:
- addrobj = Address(address=address, real_name=user.real_name)
+ addrobj = Address(address, user.real_name)
addrobj.preferences = Preferences()
user.link(addrobj)
user.preferences = Preferences()
@@ -54,16 +54,16 @@ class UserManager(object):
yield user
def get_user(self, address):
- found = Address.get_by(address=address)
+ found = Address.get_by(address=address.lower())
return found and found.user
def create_address(self, address, real_name=None):
- found = Address.get_by(address=address)
+ found = Address.get_by(address=address.lower())
if found:
- raise Errors.ExistingAddressError(address)
+ raise Errors.ExistingAddressError(found.original_address)
if real_name is None:
real_name = ''
- address = Address(address=address, real_name=real_name)
+ address = Address(address, real_name)
address.preferences = Preferences()
return address
@@ -75,7 +75,7 @@ class UserManager(object):
address.delete()
def get_address(self, address):
- return Address.get_by(address=address)
+ return Address.get_by(address=address.lower())
@property
def addresses(self):