toXML = staticmethod(format_xml) toPrettyXML = staticmethod(format_pretty_xml) toBinary = staticmethod(format_binary) toNotation = staticmethod(format_notation) undef = LLSD(None) XML_MIME_TYPE = 'application/llsd+xml' BINARY_MIME_TYPE = 'application/llsd+binary' # register converters for llsd in mulib, if it is available try: from mulib import stacked, mu stacked.NoProducer() # just to exercise stacked mu.safe_load(None) # just to exercise mu except: # mulib not available, don't print an error message since this is normal pass else: mu.add_parser(parse, XML_MIME_TYPE) mu.add_parser(parse, 'application/llsd+binary') def llsd_convert_xml(llsd_stuff, request): request.write(format_xml(llsd_stuff)) def llsd_convert_binary(llsd_stuff, request): request.write(format_binary(llsd_stuff)) for typ in [LLSD, dict, list, tuple, str, int, long, float, bool, unicode, type(None)]: stacked.add_producer(typ, llsd_convert_xml, XML_MIME_TYPE)