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