3333from roundup import hyperdb
3434from roundup import date
3535from roundup import actions
36- from roundup .anypy .strings import bs2b , b2s
36+ from roundup .anypy .strings import bs2b , b2s , u2s , is_us
3737from roundup .exceptions import *
3838from roundup .cgi .exceptions import *
3939
@@ -602,7 +602,7 @@ def get_collection(self, class_name, input):
602602 raise UsageError ("Failed to find property '%s' "
603603 "for class %s." % (i , class_name ))
604604
605-
605+
606606 else : # serve the filter purpose
607607 prop = class_obj .getprops ()[key ]
608608 # We drop properties without search permission silently
@@ -1550,7 +1550,7 @@ def dispatch(self, method, uri, input):
15501550 # FIXME: do we need to raise an error if client did not specify
15511551 # version? This may be a good thing to require. Note that:
15521552 # Accept: application/json; version=1 may not be legal but....
1553-
1553+
15541554 # Call the appropriate method
15551555 try :
15561556 # If output was defined by a prior error
@@ -1594,8 +1594,8 @@ def default(self, obj):
15941594
15951595class SimulateFieldStorageFromJson ():
15961596 '''
1597- The internals of the rest interface assume the data was sent as
1598- application/x-www-form-urlencoded. So we should have a
1597+ The internals of the rest interface assume the data was sent as
1598+ application/x-www-form-urlencoded. So we should have a
15991599 FieldStorage and MiniFieldStorage structure.
16001600
16011601 However if we want to handle json data, we need to:
@@ -1616,16 +1616,20 @@ def __init__(self, json_string):
16161616 ''' Parse the json string into an internal dict. '''
16171617 def raise_error_on_constant (x ):
16181618 raise ValueError ("Unacceptable number: %s" % x )
1619-
16201619 self .json_dict = json .loads (json_string ,
16211620 parse_constant = raise_error_on_constant )
16221621 self .value = [ self .FsValue (index , self .json_dict [index ]) for index in self .json_dict .keys () ]
16231622
16241623 class FsValue :
16251624 '''Class that does nothing but response to a .value property '''
16261625 def __init__ (self , name , val ):
1627- self .name = name
1628- self .value = val
1626+ self .name = u2s (name )
1627+ if is_us (val ):
1628+ self .value = u2s (val )
1629+ elif type (val ) == type ([]):
1630+ self .value = [ u2s (v ) for v in val ]
1631+ else :
1632+ self .value = str (val )
16291633
16301634 def __getitem__ (self , index ):
16311635 '''Return an FsValue created from the value of self.json_dict[index]
0 commit comments