'Produce a L{openid.message.Message} representing this request.
@param realm: The URL (or URL pattern) that identifies your
web site to the user when she is authorizing it.
@type realm: str
@param return_to: The URL that the OpenID provider will send the
user back to after attempting to verify her identity.
Not specifying a return_to URL means that the user will not
be returned to the site issuing the request upon its
completion.
@type return_to: str
@param immediate: If True, the OpenID provider is to send back
a response immediately, useful for behind-the-scenes
authentication attempts.  Otherwise the OpenID provider
may engage the user before providing a response.  This is
the default case, as the user may need to provide
credentials or approve the request before a positive
response can be sent.
@type immediate: bool
@returntype: L{openid.message.Message}'

def getMessage(self, realm, return_to=None, immediate=False):

    if return_to:
        return_to = oidutil.appendArgs(return_to, self.return_to_args)
    elif immediate:
        raise ValueError('"return_to"    is    mandatory    when    using    "checkid_immediate"')
    elif self.message.isOpenID1():
        raise ValueError('"return_to"    is    mandatory    for    OpenID    1    requests')
    elif self.return_to_args:
        raise ValueError('extra    "return_to"    arguments    were    specified,    but    no    return_to    was    specified')
    if immediate:
        mode = 'checkid_immediate'
    else:
        mode = 'checkid_setup'
    message = self.message.copy()
    if message.isOpenID1():
        realm_key = 'trust_root'
    else:
        realm_key = 'realm'
    message.updateArgs(OPENID_NS, {realm_key: realm, 'mode': mode, 'return_to': return_to})
    if (not self._anonymous):
        if self.endpoint.isOPIdentifier():
            claimed_id = request_identity = IDENTIFIER_SELECT
        else:
            request_identity = self.endpoint.getLocalID()
            claimed_id = self.endpoint.claimed_id
        message.setArg(OPENID_NS, 'identity', request_identity)
        if message.isOpenID2():
            message.setArg(OPENID2_NS, 'claimed_id', claimed_id)
    if self.assoc:
        message.setArg(OPENID_NS, 'assoc_handle', self.assoc.handle)
        assoc_log_msg = ('with    assocication    %s' % (self.assoc.handle,))
    else:
        assoc_log_msg = 'using    stateless    mode.'
    oidutil.log(('Generated    %s    request    to    %s    %s' % (mode, self.endpoint.server_url, assoc_log_msg)))
    return message
