'How should I be encoded?
@returns: one of ENCODE_URL, ENCODE_KVFORM, or None.  If None,
I cannot be encoded as a protocol message and should be
displayed to the user.'

def whichEncoding(self):

    if self.hasReturnTo():
        if ((self.openid_message.getOpenIDNamespace() == OPENID2_NS) and (len(self.encodeToURL()) > OPENID1_URL_LIMIT)):
            return ENCODE_HTML_FORM
        else:
            return ENCODE_URL
    if (self.openid_message is None):
        return None
    mode = self.openid_message.getArg(OPENID_NS, 'mode')
    if mode:
        if (mode not in BROWSER_REQUEST_MODES):
            return ENCODE_KVFORM
    return None
