summaryrefslogtreecommitdiff
path: root/src/mailman/model/user.py
diff options
context:
space:
mode:
authorBarry Warsaw2011-04-12 18:09:36 -0400
committerBarry Warsaw2011-04-12 18:09:36 -0400
commit5bb93de8db9b251a53968f0e1cf0b22d472e1a57 (patch)
treeaac85174fe3cea5e09113b9c9293fc484c773a66 /src/mailman/model/user.py
parent980e9dff9811466dcb9b44539d694b6eac32a17b (diff)
parent7c6633d17617ac60f11ff7de44160a9d804d4777 (diff)
downloadmailman-5bb93de8db9b251a53968f0e1cf0b22d472e1a57.tar.gz
mailman-5bb93de8db9b251a53968f0e1cf0b22d472e1a57.tar.zst
mailman-5bb93de8db9b251a53968f0e1cf0b22d472e1a57.zip
Lots of work to update the model for users, passwords, membership, testing,
and the REST API. A highlight of the merged changes: * The REST API now has a /users top-level URL under which user information can be accessed, and new users can be created. * IUsers now have a unique `user_id` which is evident in the REST API. Under testing, these uids are predictable, but otherwise, they're entirely random but guaranteed to be unique. * IUsers now have a `created_on` attribute. Like `user_id` these are predictable under testing, but otherwise reflect the actual date. * User passwords are now 'encrypted' (hashed) as defined by the config file. - new mailman.cfg variables password_scheme and password_length * IMember gets a `user` attribute which is a convenience for getting the IUser associated with the member. * mmsitepass is gone: - creator_pw_file - site_pw_file * Improved test initialization and its hook into zc.buildout.
Diffstat (limited to 'src/mailman/model/user.py')
-rw-r--r--src/mailman/model/user.py33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/mailman/model/user.py b/src/mailman/model/user.py
index f2a7c9d18..f0048c5f4 100644
--- a/src/mailman/model/user.py
+++ b/src/mailman/model/user.py
@@ -24,7 +24,8 @@ __all__ = [
'User',
]
-from storm.locals import Int, Reference, ReferenceSet, Unicode
+from storm.locals import (
+ DateTime, Int, RawStr, Reference, ReferenceSet, Unicode)
from zope.interface import implements
from mailman.config import config
@@ -35,6 +36,8 @@ from mailman.interfaces.user import IUser
from mailman.model.address import Address
from mailman.model.preferences import Preferences
from mailman.model.roster import Memberships
+from mailman.utilities.datetime import factory as date_factory
+from mailman.utilities.uid import factory as uid_factory
@@ -45,14 +48,38 @@ class User(Model):
id = Int(primary=True)
real_name = Unicode()
- password = Unicode()
+ password = RawStr()
+ _user_id = Unicode()
+ _created_on = DateTime()
addresses = ReferenceSet(id, 'Address.user_id')
preferences_id = Int()
preferences = Reference(preferences_id, 'Preferences.id')
+ def __init__(self, real_name=None, preferences=None):
+ super(User, self).__init__()
+ self._created_on = date_factory.now()
+ user_id = uid_factory.new_uid()
+ assert config.db.store.find(User, _user_id=user_id).count() == 0, (
+ 'Duplicate user id {0}'.format(user_id))
+ self._user_id = user_id
+ self.real_name = ('' if real_name is None else real_name)
+ self.preferences = preferences
+ config.db.store.add(self)
+
def __repr__(self):
- return '<User "{0}" at {1:#x}>'.format(self.real_name, id(self))
+ return '<User "{0.real_name}" ({0.user_id}) at {1:#x}>'.format(
+ self, id(self))
+
+ @property
+ def user_id(self):
+ """See `IUser`."""
+ return self._user_id
+
+ @property
+ def created_on(self):
+ """See `IUser`."""
+ return self._created_on
def link(self, address):
"""See `IUser`."""