'Do checks and create account'

def func(self):

    session = self.caller
    try:
        (playername, email, password) = self.playerinfo
    except ValueError:
        string = '\n\r    Usage    (without    <>):    create    "<playername>"    <email>    <password>'
        session.msg(string)
        return
    if ((not email) or (not password)):
        session.msg('\n\r    You    have    to    supply    an    e-mail    address    followed    by    a    password.')
        return
    if (not utils.validate_email_address(email)):
        session.msg(("'%s'    is    not    a    valid    e-mail    address." % email))
        return
    if ((not re.findall("^[\\w.    @+\\-']+$", playername)) or (not (0 < len(playername) <= 30))):
        string = "\n\r    Playername    can    max    be    30    characters    or    fewer.    Letters,    spaces,    digits    and    @/./+/-/_/'    only."
        session.msg(string)
        return
    playername = re.sub('\\s+', '    ', playername).strip()
    if PlayerDB.objects.filter(username__iexact=playername):
        session.msg(("Sorry,    there    is    already    a    player    with    the    name    '%s'." % playername))
        return
    if PlayerDB.objects.get_player_from_email(email):
        session.msg('Sorry,    there    is    already    a    player    with    that    email    address.')
        return
    if (settings.GUEST_LIST and (playername.lower() in (guest.lower() for guest in settings.GUEST_LIST))):
        string = '\n\r    That    name    is    reserved.    Please    choose    another    Playername.'
        session.msg(string)
        return
    if ((not re.findall("^[\\w.    @+\\-']+$", password)) or (not (3 < len(password)))):
        string = "\n\r    Password    should    be    longer    than    3    characers.    Letters,    spaces,    digits    and    @/./+/-/_/'    only.\nFor    best    security,    make    it    longer    than    8    characters.    You    can    also    use    a    phrase    of\nmany    words    if    you    enclose    the    password    in    double    quotes."
        session.msg(string)
        return
    bans = ServerConfig.objects.conf('server_bans')
    if (bans and (any(((tup[0] == playername.lower()) for tup in bans)) or any((tup[2].match(session.address) for tup in bans if tup[2])))):
        string = '|rYou    have    been    banned    and    cannot    continue    from    here.\nIf    you    feel    this    ban    is    in    error,    please    email    an    admin.|x'
        session.msg(string)
        session.sessionhandler.disconnect(session, 'Good    bye!    Disconnecting.')
        return
    try:
        permissions = settings.PERMISSION_PLAYER_DEFAULT
        typeclass = settings.BASE_CHARACTER_TYPECLASS
        new_player = default_unloggedin._create_player(session, playername, password, permissions, email=email)
        if new_player:
            if (MULTISESSION_MODE < 2):
                default_home = ObjectDB.objects.get_id(settings.DEFAULT_HOME)
                default_unloggedin._create_character(session, new_player, typeclass, default_home, permissions)
            string = "A    new    account    '%s'    was    created.    Welcome!"
            if ('    ' in playername):
                string += '\n\nYou    can    now    log    in    with    the    command    \'connect    "%s"    <your    password>\'.'
            else:
                string += "\n\nYou    can    now    log    with    the    command    'connect    %s    <your    password>'."
            session.msg((string % (playername, email)))
    except Exception:
        session.msg('An    error    occurred.    Please    e-mail    an    admin    if    the    problem    persists.')
        logger.log_trace()
        raise
