コード例 #1
0
ファイル: lluuid.py プロジェクト: AlexRa/Kirstens-clone
    uuid_matcher = re.compile(matcher)
    if uuid_matcher.match(id_str):
        return 1
    return 0

def uuid_bits_to_string(bits):
    i1 = _binstr2int(bits[0:4])
    i2 = _binstr2int(bits[4:6])
    i3 = _binstr2int(bits[6:8])
    i4 = _binstr2int(bits[8:10])
    i5 = _binstr2int(bits[10:12])
    i6 = _binstr2int(bits[12:16])
    return '%08lx-%04lx-%04lx-%04lx-%04lx%08lx' % (i1,i2,i3,i4,i5,i6)

def uuid_bits_to_uuid(bits):
    return UUID(uuid_bits_to_string(bits))


try:
    from mulib import stacked
    stacked.NoProducer()  # just to exercise stacked
except:
    #print "Couldn't import mulib.stacked, not registering UUID converter"
    pass
else:
    def convertUUID(uuid, req):
        req.write(str(uuid))

    stacked.add_producer(UUID, convertUUID, "*/*")
    stacked.add_producer(UUID, convertUUID, "text/html")
コード例 #2
0
    return 0


def uuid_bits_to_string(bits):
    i1 = _binstr2int(bits[0:4])
    i2 = _binstr2int(bits[4:6])
    i3 = _binstr2int(bits[6:8])
    i4 = _binstr2int(bits[8:10])
    i5 = _binstr2int(bits[10:12])
    i6 = _binstr2int(bits[12:16])
    return '%08lx-%04lx-%04lx-%04lx-%04lx%08lx' % (i1, i2, i3, i4, i5, i6)


def uuid_bits_to_uuid(bits):
    return UUID(uuid_bits_to_string(bits))


try:
    from mulib import stacked
    stacked.NoProducer()  # just to exercise stacked
except:
    #print "Couldn't import mulib.stacked, not registering UUID converter"
    pass
else:

    def convertUUID(uuid, req):
        req.write(str(uuid))

    stacked.add_producer(UUID, convertUUID, "*/*")
    stacked.add_producer(UUID, convertUUID, "text/html")
コード例 #3
0
ファイル: llsd.py プロジェクト: Kitty-xx/imprudence
    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)
        stacked.add_producer(typ, llsd_convert_xml, 'application/xml')
        stacked.add_producer(typ, llsd_convert_xml, 'text/xml')

        stacked.add_producer(typ, llsd_convert_binary, 'application/llsd+binary')

    stacked.add_producer(LLSD, llsd_convert_xml, '*/*')

    # in case someone is using the legacy mu.xml wrapper, we need to
    # tell mu to produce application/xml or application/llsd+xml
    # (based on the accept header) from raw xml. Phoenix 2008-07-21
    stacked.add_producer(mu.xml, mu.produce_raw, XML_MIME_TYPE)
    stacked.add_producer(mu.xml, mu.produce_raw, 'application/xml')


コード例 #4
0
    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)
        stacked.add_producer(typ, llsd_convert_xml, 'application/xml')
        stacked.add_producer(typ, llsd_convert_xml, 'text/xml')

        stacked.add_producer(typ, llsd_convert_binary, 'application/llsd+binary')

    stacked.add_producer(LLSD, llsd_convert_xml, '*/*')

    # in case someone is using the legacy mu.xml wrapper, we need to
    # tell mu to produce application/xml or application/llsd+xml
    # (based on the accept header) from raw xml. Phoenix 2008-07-21
    stacked.add_producer(mu.xml, mu.produce_raw, XML_MIME_TYPE)
    stacked.add_producer(mu.xml, mu.produce_raw, 'application/xml')


コード例 #5
0
ファイル: llsd.py プロジェクト: AlexRa/Kirstens-clone

undef = LLSD(None)

# 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, 'application/llsd+xml')
    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, float, bool, unicode, type(None)]:
        stacked.add_producer(typ, llsd_convert_xml, 'application/llsd+xml')
        stacked.add_producer(typ, llsd_convert_xml, 'application/xml')
        stacked.add_producer(typ, llsd_convert_xml, 'text/xml')

        stacked.add_producer(typ, llsd_convert_binary, 'application/llsd+binary')

    stacked.add_producer(LLSD, llsd_convert_xml, '*/*')
コード例 #6
0
    def llsd_convert_json(llsd_stuff, request):
        callback = request.get_header('callback')
        if callback is not None:
            ## See Yahoo's ajax documentation for information about using this
            ## callback style of programming
            ## http://developer.yahoo.com/common/json.html#callbackparam
            req.write("%s(%s)" % (callback, simplejson.dumps(llsd_stuff)))
        else:
            req.write(simplejson.dumps(llsd_stuff))

    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, float, bool, unicode,
            type(None)
    ]:
        stacked.add_producer(typ, llsd_convert_json, 'application/json')

        stacked.add_producer(typ, llsd_convert_xml, 'application/llsd+xml')
        stacked.add_producer(typ, llsd_convert_xml, 'application/xml')
        stacked.add_producer(typ, llsd_convert_xml, 'text/xml')

        stacked.add_producer(typ, llsd_convert_binary,
                             'application/llsd+binary')

    stacked.add_producer(LLSD, llsd_convert_xml, '*/*')