Changeset 4788
- Timestamp:
- 06/20/08 04:49:59 (2 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
projects/TurboJson/branches/1.1/turbojson/jsonsupport.py
r4728 r4788 6 6 class JsonSupport(object): 7 7 8 encoding = 'utf-8' 9 8 10 def __init__(self, extra_vars_func=None, options=None): 9 11 opts = {} … … 12 14 continue 13 15 opt = option[5:] 14 if opt == 'assume_encoding': 15 opt = 'encoding' 16 opts[opt] = options[option] 16 if opt == 'encoding': 17 self.encoding = options[option] or self.encoding 18 else: 19 if opt == 'assume_encoding': 20 opt = 'encoding' 21 opts[opt] = options[option] 17 22 self.encoder = jsonify.GenericJSON(**opts) 18 23 … … 31 36 """ 32 37 [info.pop(item) for item in info.copy() if (item.startswith("tg_") and item != "tg_flash")] 33 return self.encoder.encode(info) 38 output = self.encoder.encode(info) 39 if isinstance(output, unicode): 40 output = output.encode(self.encoding) 41 return output 34 42 35 43 def get_content_type(self, **kw): projects/TurboJson/trunk/turbojson/jsonsupport.py
r4729 r4788 6 6 class JsonSupport(object): 7 7 8 encoding = 'utf-8' 9 8 10 def __init__(self, extra_vars_func=None, options=None): 9 11 opts = {} … … 12 14 continue 13 15 opt = option[5:] 14 if opt == 'assume_encoding': 15 opt = 'encoding' 16 opts[opt] = options[option] 16 if opt == 'encoding': 17 self.encoding = options[option] or self.encoding 18 else: 19 if opt == 'assume_encoding': 20 opt = 'encoding' 21 opts[opt] = options[option] 17 22 self.encoder = jsonify.GenericJSON(**opts) 18 23 … … 33 38 if item.startswith("tg_") and item != "tg_flash": 34 39 del info[item] 35 return self.encoder.encode(info) 40 output = self.encoder.encode(info) 41 if isinstance(output, unicode): 42 output = output.encode(self.encoding) 43 return output