~rashi007/mailman/docsfix

« back to all changes in this revision

Viewing changes to src/mailman/rest/users.py

  • Committer: Barry Warsaw
  • Date: 2015-02-10 00:41:46 UTC
  • Revision ID: barry@list.org-20150210004146-5l3xgnpie95ju1s6
 * When deleting a user via REST, make sure all linked addresses are deleted.
   Found by Andrew Stuart.  (LP: #1419519)

Show diffs side-by-side

added added

removed removed

Lines of Context:
192
192
        for member in self._user.memberships.members:
193
193
            member.unsubscribe()
194
194
        user_manager = getUtility(IUserManager)
195
 
        for address in self._user.addresses:
 
195
        # SQLAlchemy is susceptable to delete-elements-while-iterating bugs so
 
196
        # first figure out all the addresses we want to delete, then in a
 
197
        # separate pass, delete those addresses.  (See LP: #1419519)
 
198
        delete = list(self._user.addresses)
 
199
        for address in delete:
196
200
            user_manager.delete_address(address)
197
201
        user_manager.delete_user(self._user)
198
202
        no_content(response)