aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/lib
diff options
context:
space:
mode:
authorMcCabe Maxsted2009-01-14 07:51:24 -0700
committerMcCabe Maxsted2009-01-14 07:51:24 -0700
commit15249add53e27895fa9a7884adafad1bd319ae4e (patch)
tree4743a5fdf592d537c70aa3308e3de22dc8a492bc /linden/indra/lib
parentAdded text to IM window about inventory transfers (diff)
downloadmeta-impy-15249add53e27895fa9a7884adafad1bd319ae4e.zip
meta-impy-15249add53e27895fa9a7884adafad1bd319ae4e.tar.gz
meta-impy-15249add53e27895fa9a7884adafad1bd319ae4e.tar.bz2
meta-impy-15249add53e27895fa9a7884adafad1bd319ae4e.tar.xz
Added the 'Return to World' inventory option
Diffstat (limited to 'linden/indra/lib')
-rw-r--r--linden/indra/lib/python/indra/base/llsd.py79
1 files changed, 63 insertions, 16 deletions
diff --git a/linden/indra/lib/python/indra/base/llsd.py b/linden/indra/lib/python/indra/base/llsd.py
index 521b79c..e6141b6 100644
--- a/linden/indra/lib/python/indra/base/llsd.py
+++ b/linden/indra/lib/python/indra/base/llsd.py
@@ -36,10 +36,13 @@ import re
36from indra.util.fastest_elementtree import ElementTreeError, fromstring 36from indra.util.fastest_elementtree import ElementTreeError, fromstring
37from indra.base import lluuid 37from indra.base import lluuid
38 38
39try: 39# cllsd.c in server/server-1.25 has memory leaks,
40 import cllsd 40# so disabling cllsd for now
41except ImportError: 41#try:
42 cllsd = None 42# import cllsd
43#except ImportError:
44# cllsd = None
45cllsd = None
43 46
44int_regex = re.compile(r"[-+]?\d+") 47int_regex = re.compile(r"[-+]?\d+")
45real_regex = re.compile(r"[-+]?(\d+(\.\d*)?|\d*\.\d+)([eE][-+]?\d+)?") 48real_regex = re.compile(r"[-+]?(\d+(\.\d*)?|\d*\.\d+)([eE][-+]?\d+)?")
@@ -47,7 +50,7 @@ alpha_regex = re.compile(r"[a-zA-Z]+")
47date_regex = re.compile(r"(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})T" 50date_regex = re.compile(r"(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})T"
48 r"(?P<hour>\d{2}):(?P<minute>\d{2}):(?P<second>\d{2})" 51 r"(?P<hour>\d{2}):(?P<minute>\d{2}):(?P<second>\d{2})"
49 r"(?P<second_float>(\.\d+)?)Z") 52 r"(?P<second_float>(\.\d+)?)Z")
50#date: d"YYYY-MM-DDTHH:MM:SS.FFZ" 53#date: d"YYYY-MM-DDTHH:MM:SS.FFFFFFZ"
51 54
52class LLSDParseError(Exception): 55class LLSDParseError(Exception):
53 pass 56 pass
@@ -69,14 +72,7 @@ BOOL_FALSE = ('0', '0.0', 'false', '')
69 72
70def format_datestr(v): 73def format_datestr(v):
71 """ Formats a datetime object into the string format shared by xml and notation serializations.""" 74 """ Formats a datetime object into the string format shared by xml and notation serializations."""
72 second_str = "" 75 return v.isoformat() + 'Z'
73 if v.microsecond > 0:
74 seconds = v.second + float(v.microsecond) / 1e6
75 second_str = "%05.2f" % seconds
76 else:
77 second_str = "%02d" % v.second
78 return '%s%sZ' % (v.strftime('%Y-%m-%dT%H:%M:'), second_str)
79
80 76
81def parse_datestr(datestr): 77def parse_datestr(datestr):
82 """Parses a datetime object from the string format shared by xml and notation serializations.""" 78 """Parses a datetime object from the string format shared by xml and notation serializations."""
@@ -133,6 +129,7 @@ def date_to_python(node):
133 if not val: 129 if not val:
134 val = "1970-01-01T00:00:00Z" 130 val = "1970-01-01T00:00:00Z"
135 return parse_datestr(val) 131 return parse_datestr(val)
132
136 133
137def uri_to_python(node): 134def uri_to_python(node):
138 val = node.text or '' 135 val = node.text or ''
@@ -969,6 +966,9 @@ class LLSD(object):
969 966
970undef = LLSD(None) 967undef = LLSD(None)
971 968
969XML_MIME_TYPE = 'application/llsd+xml'
970BINARY_MIME_TYPE = 'application/llsd+binary'
971
972# register converters for llsd in mulib, if it is available 972# register converters for llsd in mulib, if it is available
973try: 973try:
974 from mulib import stacked, mu 974 from mulib import stacked, mu
@@ -978,7 +978,7 @@ except:
978 # mulib not available, don't print an error message since this is normal 978 # mulib not available, don't print an error message since this is normal
979 pass 979 pass
980else: 980else:
981 mu.add_parser(parse, 'application/llsd+xml') 981 mu.add_parser(parse, XML_MIME_TYPE)
982 mu.add_parser(parse, 'application/llsd+binary') 982 mu.add_parser(parse, 'application/llsd+binary')
983 983
984 def llsd_convert_xml(llsd_stuff, request): 984 def llsd_convert_xml(llsd_stuff, request):
@@ -987,11 +987,58 @@ else:
987 def llsd_convert_binary(llsd_stuff, request): 987 def llsd_convert_binary(llsd_stuff, request):
988 request.write(format_binary(llsd_stuff)) 988 request.write(format_binary(llsd_stuff))
989 989
990 for typ in [LLSD, dict, list, tuple, str, int, float, bool, unicode, type(None)]: 990 for typ in [LLSD, dict, list, tuple, str, int, long, float, bool, unicode, type(None)]:
991 stacked.add_producer(typ, llsd_convert_xml, 'application/llsd+xml') 991 stacked.add_producer(typ, llsd_convert_xml, XML_MIME_TYPE)
992 stacked.add_producer(typ, llsd_convert_xml, 'application/xml') 992 stacked.add_producer(typ, llsd_convert_xml, 'application/xml')
993 stacked.add_producer(typ, llsd_convert_xml, 'text/xml') 993 stacked.add_producer(typ, llsd_convert_xml, 'text/xml')
994 994
995 stacked.add_producer(typ, llsd_convert_binary, 'application/llsd+binary') 995 stacked.add_producer(typ, llsd_convert_binary, 'application/llsd+binary')
996 996
997 stacked.add_producer(LLSD, llsd_convert_xml, '*/*') 997 stacked.add_producer(LLSD, llsd_convert_xml, '*/*')
998
999 # in case someone is using the legacy mu.xml wrapper, we need to
1000 # tell mu to produce application/xml or application/llsd+xml
1001 # (based on the accept header) from raw xml. Phoenix 2008-07-21
1002 stacked.add_producer(mu.xml, mu.produce_raw, XML_MIME_TYPE)
1003 stacked.add_producer(mu.xml, mu.produce_raw, 'application/xml')
1004
1005
1006
1007# mulib wsgi stuff
1008# try:
1009# from mulib import mu, adapters
1010#
1011# # try some known attributes from mulib to be ultra-sure we've imported it
1012# mu.get_current
1013# adapters.handlers
1014# except:
1015# # mulib not available, don't print an error message since this is normal
1016# pass
1017# else:
1018# def llsd_xml_handler(content_type):
1019# def handle_llsd_xml(env, start_response):
1020# llsd_stuff, _ = mu.get_current(env)
1021# result = format_xml(llsd_stuff)
1022# start_response("200 OK", [('Content-Type', content_type)])
1023# env['mu.negotiated_type'] = content_type
1024# yield result
1025# return handle_llsd_xml
1026#
1027# def llsd_binary_handler(content_type):
1028# def handle_llsd_binary(env, start_response):
1029# llsd_stuff, _ = mu.get_current(env)
1030# result = format_binary(llsd_stuff)
1031# start_response("200 OK", [('Content-Type', content_type)])
1032# env['mu.negotiated_type'] = content_type
1033# yield result
1034# return handle_llsd_binary
1035#
1036# adapters.DEFAULT_PARSERS[XML_MIME_TYPE] = parse
1037
1038# for typ in [LLSD, dict, list, tuple, str, int, float, bool, unicode, type(None)]:
1039# for content_type in (XML_MIME_TYPE, 'application/xml'):
1040# adapters.handlers.set_handler(typ, llsd_xml_handler(content_type), content_type)
1041#
1042# adapters.handlers.set_handler(typ, llsd_binary_handler(BINARY_MIME_TYPE), BINARY_MIME_TYPE)
1043#
1044# adapters.handlers.set_handler(LLSD, llsd_xml_handler(XML_MIME_TYPE), '*/*')