'Convert the message to text.
The I{origin}, I{relativize}, and any other keyword
arguments are passed to the rrset to_wire() method.
@rtype: string'

def to_text(self, origin=None, relativize=True, **kw):

    s = StringIO()
    s.write((u'id    %d\n' % self.id))
    s.write((u'opcode    %s\n' % dns.opcode.to_text(dns.opcode.from_flags(self.flags))))
    rc = dns.rcode.from_flags(self.flags, self.ednsflags)
    s.write((u'rcode    %s\n' % dns.rcode.to_text(rc)))
    s.write((u'flags    %s\n' % dns.flags.to_text(self.flags)))
    if (self.edns >= 0):
        s.write((u'edns    %s\n' % self.edns))
        if (self.ednsflags != 0):
            s.write((u'eflags    %s\n' % dns.flags.edns_to_text(self.ednsflags)))
        s.write((u'payload    %d\n' % self.payload))
    is_update = dns.opcode.is_update(self.flags)
    if is_update:
        s.write(u';ZONE\n')
    else:
        s.write(u';QUESTION\n')
    for rrset in self.question:
        s.write(rrset.to_text(origin, relativize, **kw))
        s.write(u'\n')
    if is_update:
        s.write(u';PREREQ\n')
    else:
        s.write(u';ANSWER\n')
    for rrset in self.answer:
        s.write(rrset.to_text(origin, relativize, **kw))
        s.write(u'\n')
    if is_update:
        s.write(u';UPDATE\n')
    else:
        s.write(u';AUTHORITY\n')
    for rrset in self.authority:
        s.write(rrset.to_text(origin, relativize, **kw))
        s.write(u'\n')
    s.write(u';ADDITIONAL\n')
    for rrset in self.additional:
        s.write(rrset.to_text(origin, relativize, **kw))
        s.write(u'\n')
    return s.getvalue()[:(-1)]
