Merge lp:~nkarageuzian/mailman/usermanagement into lp:mailman
Proposed by
nicolask
Status: | Rejected |
---|---|
Rejected by: | Barry Warsaw |
Proposed branch: | lp:~nkarageuzian/mailman/usermanagement |
Merge into: | lp:mailman |
Diff against target: |
103 lines (+81/-3) 2 files modified
src/mailman/model/tests/test_usermanager.py (+67/-0) src/mailman/model/usermanager.py (+14/-3) |
To merge this branch: | bzr merge lp:~nkarageuzian/mailman/usermanagement |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mailman Coders | Pending | ||
Review via email: mp+200128@code.launchpad.net |
Description of the change
solves the use case:
user sends a mail to the list without subscribing nor registering
admin accepts message
user wants to register to mailman through API but
create_user method fails as sender's address is registered.
and add tests for usermanager and the create_user function.
To post a comment you must log in.
nicolask - thanks very much for the contribution to Mailman! I'm afraid I'm going to have to reject this merge proposal though because I think this issue needs to be solved at a different level. The model tries to be as simple as possible, and because the IUser object is a fundamental object, the IUserManager. create_ user() method should not implement these additional semantics. On the mailing list, I outlined an approach that I think would be better.
In the hopes that you'll continue to contribute to Mailman, I'd like to offer some additional style feedback on your diff. Again, thanks for working on Mailman!
=== added file 'src/mailman/ model/tests/ test_usermanage r.py' model/tests/ test_usermanage r.py 1970-01-01 00:00:00 +0000 model/tests/ test_usermanage r.py 2013-12-28 10:18:08 +0000 (unittest. TestCase) : IAddress) ('<email address hidden>','No one')
--- src/mailman/
+++ src/mailman/
> +class TestUserManager
> + """Test usermanager."""
> +
> + layer = ConfigLayer
> +
> + def setUp(self):
> + self._mlist = create_list('<email address hidden>')
> + #getUtility(
Of course, you can get rid of that commented out line, but also, since your
tests all use the IUserManager utility, it might be better to do something
like this in the setUp():
and then use self._user_manager instead of having to get the utility every
time.
> + user(self) : IUserManager) .create_ user( user_existing_ address_ user(self) : IUserManager) .create_ user( es(ExistingAddr essError, getUtility( IUserManager) .create_ user,*(
> + def test_create_
> + anne = getUtility(
> + '<email address hidden>', 'Anne Person')
> +
> + def test_create_
> + anne = getUtility(
> + '<email address hidden>', 'Anne Person')
> + self.assertRais
> + '<email address hidden>', 'Anne Person'))
You'll want to make sure this line is less than 80 characters wide. Also, you
should need the * there. I think the following would work better:
> + user_existing_ address_ no_user( self): IUserManager) .create_ user( IUserManager) .create_ user( (anne.user_ id != noone.user_id)
> + def test_create_
> + anne = getUtility(
> + '<email address hidden>', 'Anne Person')
> + noone = getUtility(
> + '<email address hidden>','No one')
> + self.assertTrue
It would be better to use self.assertNotE qual() here, since the error message
is better should the test ever fail. (Also, remember, a single space comes
after commas in an argument list.)
https:/ /docs.python. org/2.7/ library/ unittest. html?highlight= unittest# assert- methods
=== modified file 'src/mailman/ model/usermanag er.py' model/usermanag er.py 2013-01-01 14:05:42 +0000 model/usermanag er.py 2013-12-28 10:18:08 +0000 IUserManager)
--- src/mailman/
+++ src/mailman/
> @@ -40,13 +40,24 @@
> @implementer(
> class UserManager:
> """See `IUserManager`."""
> -
> - def create_user(self, email=None, display_name=None):
> + @dbconnection
> + def create_user(s...