[Mailman-Developers] "Address already exists" when creating users, but it creates a new user anyway

Andrew Stuart andrew.stuart at supercoders.com.au
Wed Feb 4 23:32:38 CET 2015


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 <barry at list.org> 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



More information about the Mailman-Developers mailing list