def generate_username(membersuite_object):
    """Return a username suitable for storing in auth.User.username.

    Has to be <= 30 characters long.  (Until we drop support for
    Django 1.4, after which we can define a custom User model with
    a larger username field.)

    We want to incorporate the membersuite_id in the username.
    Those look like this:

        6faf90e4-0032-c842-a28a-0b3c8b856f80

    That's 36 characters, too long for username.  Making the
    assumption that those leading digits will always be there in
    every ID.  Since they're not needed to generate a unique
    value, they can go.

    After chomping the intro, we're at 27 characters, so we
    insert "ms" in the front.

    """
    username = "ms" + membersuite_object.membersuite_id[len("6faf90e4"):]
    return username