'Construct me from an OpenID Message.
@param message: The OpenID associate request
@type message: openid.message.Message
@returntype: L{AssociateRequest}'

def fromMessage(klass, message, op_endpoint=UNUSED):

    if message.isOpenID1():
        session_type = message.getArg(OPENID_NS, 'session_type')
        if (session_type == 'no-encryption'):
            oidutil.log('Received    OpenID    1    request    with    a    no-encryption    assocaition    session    type.    Continuing    anyway.')
        elif (not session_type):
            session_type = 'no-encryption'
    else:
        session_type = message.getArg(OPENID2_NS, 'session_type')
        if (session_type is None):
            raise ProtocolError(message, text='session_type    missing    from    request')
    try:
        session_class = klass.session_classes[session_type]
    except KeyError:
        raise ProtocolError(message, ('Unknown    session    type    %r' % (session_type,)))
    try:
        session = session_class.fromMessage(message)
    except ValueError as why:
        raise ProtocolError(message, ('Error    parsing    %s    session:    %s' % (session_class.session_type, why[0])))
    assoc_type = message.getArg(OPENID_NS, 'assoc_type', 'HMAC-SHA1')
    if (assoc_type not in session.allowed_assoc_types):
        fmt = 'Session    type    %s    does    not    support    association    type    %s'
        raise ProtocolError(message, (fmt % (session_type, assoc_type)))
    self = klass(session, assoc_type)
    self.message = message
    self.namespace = message.getOpenIDNamespace()
    return self
