human
Complete this python program:
def email_channel():
assistant
#Here is the Python code you requested.

    """RESTful CRUD controller for Inbound Email channels
    @ToDo: Allow selection of a specific Channel for Alerts
    """
    def prep(r):
        table = r.table
        tablename = 'msg_email_channel'
        s3db.configure(tablename, deletable=False)
        if (not r.id):
            query = ((table.deleted == False) & (table.enabled == True))
            organisation_id = auth.user.organisation_id
            if organisation_id:
                query &= ((table.organisation_id == organisation_id) | (table.organisation_id == None))
            channels = db(query).select(table.id, table.organisation_id)
            if (organisation_id and (len(channels) > 1)):
                _channels = channels.find((lambda row: (row.organisation_id == organisation_id)))
                if (not _channels):
                    _channels = channels.find((lambda row: (row.organisation_id == None)))
                record = _channels.first()
            else:
                record = channels.first()
            if record:
                record_id = record.id
                r.id = record_id
                r.resource.add_filter((table.id == record_id))
                r.method = 'update'
            else:
                r.method = 'create'
        if r.interactive:
            table.server.label = T('Server')
            table.protocol.label = T('Protocol')
            table.use_ssl.label = 'SSL'
            table.port.label = T('Port')
            table.username.label = T('Username')
            table.password.label = T('Password')
            table.delete_from_server.label = T('Delete    from    Server?')
            table.port.comment = DIV(_class='tooltip', _title=('%s|%s' % (T('Port'), T('For    POP-3    this    is    usually    110    (995    for    SSL),    for    IMAP    this    is    usually    143    (993    for    IMAP).'))))
            table.delete_from_server.comment = DIV(_class='tooltip', _title=('%s|%s' % (T('Delete'), T('If    this    is    set    to    True    then    mails    will    be    deleted    from    the    server    after    downloading.'))))
            s3.crud_strings[tablename] =...