Re: [Mailman-Developers] "Address already exists" when creating users, but it creates a new user anyway
On Feb 05, 2015, at 09:32 AM, Andrew Stuart wrote: >After a bit of deep cave diving into the code I suspect it’s this in >model/usermanager.py You're exactly right. Thanks for filing LP: #1418280. I'll commit your fix along with some new tests. Cheers, -Barry ___ Mailman-Developers mailing list Mailman-Developers@python.org https://mail.python.org/mailman/listinfo/mailman-developers Mailman FAQ: http://wiki.list.org/x/AgA3 Searchable Archives: http://www.mail-archive.com/mailman-developers%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-developers/archive%40jab.org Security Policy: http://wiki.list.org/x/QIA9
Re: [Mailman-Developers] "Address already exists" when creating users, but it creates a new user anyway
After a bit of deep cave diving into the code I suspect it’s this in model/usermanager.py This function appears to create a user before it checks to see if the address exists, with the result that multiple users are created when the address already exists. @implementer(IUserManager) class UserManager: """See `IUserManager`.""" def create_user(self, email=None, display_name=None): """See `IUserManager`.""" user = User(display_name, Preferences()) if email: address = self.create_address(email, display_name) user.link(address) return user this seems to fix the problem - but please don’t trust my solution - needs verification. @implementer(IUserManager) class UserManager: """See `IUserManager`.""" def create_user(self, email=None, display_name=None): """See `IUserManager`.""" if email: address = self.create_address(email, display_name) user = User(display_name, Preferences()) if email: user.link(address) return user On 5 Feb 2015, at 7:59 am, Barry Warsaw wrote: On Feb 05, 2015, at 07:23 AM, Andrew Stuart wrote: > To get the source I do: > > bzr branch lp:mailman > > Is this the correct way? > > I’m using Python 3.4 Yep, exactly so. Thanks. I'll give it a go tonight. -B ___ Mailman-Developers mailing list Mailman-Developers@python.org https://mail.python.org/mailman/listinfo/mailman-developers Mailman FAQ: http://wiki.list.org/x/AgA3 Searchable Archives: http://www.mail-archive.com/mailman-developers%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-developers/archive%40jab.org Security Policy: http://wiki.list.org/x/QIA9
Re: [Mailman-Developers] "Address already exists" when creating users, but it creates a new user anyway
Hi Andrew, Thanks for the detailed response. I'll try to find some time tonight to go through your recipe step-by-step. Some questions in the meantime: On Feb 04, 2015, at 09:26 PM, Andrew Stuart wrote: >For a clean start I deleted my Mailman 3 installation. I downloaded the >latest version and installed it. Are you working from the 3.0b5 tarball or the bzr trunk? If the former, are you using the "A" release (Python 2.7) or the "B" release (Python 3.4)? If you're using the tarball, can you please try again with the head of the bzr trunk? Cheers, -Barry ___ Mailman-Developers mailing list Mailman-Developers@python.org https://mail.python.org/mailman/listinfo/mailman-developers Mailman FAQ: http://wiki.list.org/x/AgA3 Searchable Archives: http://www.mail-archive.com/mailman-developers%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-developers/archive%40jab.org Security Policy: http://wiki.list.org/x/QIA9
Re: [Mailman-Developers] "Address already exists" when creating users, but it creates a new user anyway
After executing the curl command: curl -X POST --data "email=mailmanad...@example.org" --header "authorization: Basic cmVzdGFkbWluOnJlc3RwYXNz" http://localhost:8001/3.0/users The log file adds the following: Feb 04 11:30:05 2015 (17776) BEGIN (implicit) Feb 04 11:30:05 2015 (17776) SELECT count(*) AS count_1 FROM (SELECT uid.id AS uid_id, uid.uid AS uid_uid FROM uid WHERE uid.uid = ?) AS anon_1 Feb 04 11:30:05 2015 (17776) ('57fdf5a214334b388d6efc3c375dc392',) Feb 04 11:30:05 2015 (17776) INSERT INTO uid (uid) VALUES (?) Feb 04 11:30:05 2015 (17776) ('57fdf5a214334b388d6efc3c375dc392',) Feb 04 11:30:05 2015 (17776) SELECT count(*) AS count_1 FROM (SELECT user.password AS user_password, user.id AS user_id, user.display_name AS user_display_name, user._user_id AS user__user_id, user._created_on AS user__created_on, user._preferred_address_id AS user__preferred_address_id, user.preferences_id AS user_preferences_id FROM user WHERE user._user_id = ?) AS anon_1 Feb 04 11:30:05 2015 (17776) ('57fdf5a214334b388d6efc3c375dc392',) Feb 04 11:30:05 2015 (17776) INSERT INTO preferences (acknowledge_posts, hide_address, preferred_language, receive_list_copy, receive_own_postings, delivery_mode, delivery_status) VALUES (?, ?, ?, ?, ?, ?, ?) Feb 04 11:30:05 2015 (17776) (None, None, None, None, None, None, None) Feb 04 11:30:05 2015 (17776) INSERT INTO user (display_name, password, _user_id, _created_on, _preferred_address_id, preferences_id) VALUES (?, ?, ?, ?, ?, ?) Feb 04 11:30:05 2015 (17776) ('', None, '57fdf5a214334b388d6efc3c375dc392', '2015-02-04 11:30:05.112836', None, 7) Feb 04 11:30:05 2015 (17776) SELECT count(*) AS count_1 FROM (SELECT address.verified_on AS address_verified_on, address.id AS address_id, address.email AS address_email, address._original AS address__original, address.display_name AS address_display_name, address.registered_on AS address_registered_on, address.user_id AS address_user_id, address.preferences_id AS address_preferences_id FROM address WHERE address.email = ?) AS anon_1 Feb 04 11:30:05 2015 (17776) ('mailmanad...@example.org',) Feb 04 11:30:05 2015 (17776) SELECT address.verified_on AS address_verified_on, address.id AS address_id, address.email AS address_email, address._original AS address__original, address.display_name AS address_display_name, address.registered_on AS address_registered_on, address.user_id AS address_user_id, address.preferences_id AS address_preferences_id FROM address WHERE address.email = ? LIMIT ? OFFSET ? Feb 04 11:30:05 2015 (17776) ('mailmanad...@example.org', 1, 0) Feb 04 11:30:05 2015 (17776) COMMIT ___ Mailman-Developers mailing list Mailman-Developers@python.org https://mail.python.org/mailman/listinfo/mailman-developers Mailman FAQ: http://wiki.list.org/x/AgA3 Searchable Archives: http://www.mail-archive.com/mailman-developers%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-developers/archive%40jab.org Security Policy: http://wiki.list.org/x/QIA9
Re: [Mailman-Developers] "Address already exists" when creating users, but it creates a new user anyway
It’s reproducible for me, I’m not sure what might be different in our configurations. For a clean start I deleted my Mailman 3 installation. I downloaded the latest version and installed it. I deleted and recreated my databases after first making sure they were empty. To see the problem I execute the following command, which instructs the REST API to create a new user with email address of mailmanad...@example.org (you should be able to execute this too, it’s the default REST username and password in the authorization header) curl -X POST --data "email=mailmanad...@example.org" --header "authorization: Basic cmVzdGFkbWluOnJlc3RwYXNz" http://localhost:8001/3.0/users Each time the command above is executed, an additional record is added to preferences, uid and user, despite reporting an “address already exists” error. I’m definitely not running anything else that would be accessing the REST API. I tried it on both Postgres and sqlite and got the same problem. I had a look at src/mailman/rest/users.py to see if I could see a bug but there wasn’t anything obvious that would lead to this happening. Here is the output of a sqlite dump after running the above curl command three times. (venv3.4)ubuntu@server01:~/mailman/var/data$ sqlite3 sqlite.db .dump PRAGMA foreign_keys=OFF; BEGIN TRANSACTION; CREATE TABLE preferences ( id INTEGER NOT NULL, acknowledge_posts BOOLEAN, hide_address BOOLEAN, preferred_language VARCHAR, receive_list_copy BOOLEAN, receive_own_postings BOOLEAN, delivery_mode INTEGER, delivery_status INTEGER, PRIMARY KEY (id), CHECK (acknowledge_posts IN (0, 1)), CHECK (hide_address IN (0, 1)), CHECK (receive_list_copy IN (0, 1)), CHECK (receive_own_postings IN (0, 1)) ); INSERT INTO "preferences" VALUES(1,NULL,NULL,NULL,NULL,NULL,NULL,NULL); INSERT INTO "preferences" VALUES(2,NULL,NULL,NULL,NULL,NULL,NULL,NULL); INSERT INTO "preferences" VALUES(3,NULL,NULL,NULL,NULL,NULL,NULL,NULL); INSERT INTO "preferences" VALUES(4,NULL,NULL,NULL,NULL,NULL,NULL,NULL); CREATE TABLE domain ( id INTEGER NOT NULL, mail_host VARCHAR, base_url VARCHAR, description VARCHAR, contact_address VARCHAR, PRIMARY KEY (id) ); CREATE TABLE mailinglist ( id INTEGER NOT NULL, list_name VARCHAR, mail_host VARCHAR, list_id VARCHAR, allow_list_posts BOOLEAN, include_rfc2369_headers BOOLEAN, advertised BOOLEAN, anonymous_list BOOLEAN, created_at DATETIME, next_request_id INTEGER, next_digest_number INTEGER, digest_last_sent_at DATETIME, volume INTEGER, last_post_at DATETIME, accept_these_nonmembers BLOB, admin_immed_notify BOOLEAN, admin_notify_mchanges BOOLEAN, administrivia BOOLEAN, archive_policy INTEGER, autoresponse_grace_period DATETIME, autorespond_owner INTEGER, autoresponse_owner_text VARCHAR, autorespond_postings INTEGER, autoresponse_postings_text VARCHAR, autorespond_requests INTEGER, autoresponse_request_text VARCHAR, filter_action INTEGER, filter_content BOOLEAN, collapse_alternatives BOOLEAN, convert_html_to_plaintext BOOLEAN, bounce_info_stale_after DATETIME, bounce_matching_headers VARCHAR, bounce_notify_owner_on_disable BOOLEAN, bounce_notify_owner_on_removal BOOLEAN, bounce_score_threshold INTEGER, bounce_you_are_disabled_warnings INTEGER, bounce_you_are_disabled_warnings_interval DATETIME, forward_unrecognized_bounces_to INTEGER, process_bounces BOOLEAN, default_member_action INTEGER, default_nonmember_action INTEGER, description VARCHAR, digest_footer_uri VARCHAR, digest_header_uri VARCHAR, digest_is_default BOOLEAN, digest_send_periodic BOOLEAN, digest_size_threshold FLOAT, digest_volume_frequency INTEGER, digestable BOOLEAN, discard_these_nonmembers BLOB, emergency BOOLEAN, encode_ascii_prefixes BOOLEAN, first_strip_reply_to BOOLEAN, footer_uri VARCHAR, forward_auto_discards BOOLEAN, gateway_to_mail BOOLEAN, gateway_to_news BOOLEAN, goodbye_message_uri VARCHAR, header_matches BLOB, header_uri VARCHAR, hold_these_nonmembers BLOB, info VARCHAR, linked_newsgroup VARCHAR, max_days_to_hold INTEGER, max_message_size INTEGER, max_num_recipients INTEGER, member_moderation_notice VARCHAR, mime_is_default_digest BOOLEAN, moderator_password BLOB, newsgroup_moderation INTEGER, nntp_prefix_subject_too BOOLEAN, nondigestable BOOLEAN, nonmember_rejection_notice VARCHAR, obscure_
Re: [Mailman-Developers] "Address already exists" when creating users, but it creates a new user anyway
On Feb 01, 2015, at 07:23 PM, Andrew Stuart wrote: >In the commands below you can see that I start by getting a list of users, it >returns "total_size": 1 How was this user created and with what email address? >I then execute a POST to the REST API multiple times. Each time it says >“Address already exists”, and then getting a list of users says total_size": >2 > >Is this the way its intended to work or a bug? Nope, and I can't reproduce it. Are you sure there are no other processes running, and nothing else hitting the REST API that could be racing with that POST? Try tailing the mailman.log and watching for http activity. Cheers, -Barry ___ Mailman-Developers mailing list Mailman-Developers@python.org https://mail.python.org/mailman/listinfo/mailman-developers Mailman FAQ: http://wiki.list.org/x/AgA3 Searchable Archives: http://www.mail-archive.com/mailman-developers%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-developers/archive%40jab.org Security Policy: http://wiki.list.org/x/QIA9