From 17887e4d1e56915647e1d395e18573db2b9ea3ba Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Mon, 4 Apr 2011 14:32:17 -0400 Subject: More fleshing out of the users REST API. * Add a 'uid factory' which allows us to return predictable unique ids for various testing purposes, e.g. user ids. This should work even in the case of cross-subprocess uid generation. * REST access to individual users, or the set of all users. * User objects now have a created_on attribute. * Users can be created through the web, but must have an email address. * Add a [devmode] 'testing' variable for communicating to qrunner subprocesses that we're running in testing mode. This allows us to coordinate factories and such in the qrunner processes. * layers.is_testing() for more consistent API. * Give AddressError a .address attribute for better diagnostics. --- src/mailman/model/user.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/mailman/model/user.py') diff --git a/src/mailman/model/user.py b/src/mailman/model/user.py index 05ce356ca..39f4fa240 100644 --- a/src/mailman/model/user.py +++ b/src/mailman/model/user.py @@ -58,7 +58,10 @@ class User(Model): def __init__(self, real_name=None, preferences=None): super(User, self).__init__() self._created_on = date_factory.now() - self._user_id = uid_factory.new_uid() + 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) -- cgit v1.2.3-70-g09d2