Changeset 8335 for mauRepo


Ignore:
Timestamp:
12/06/12 10:54:39 (7 years ago)
Author:
mnagni
Message:

Fixed how the JSON encoder manages some escape characters

Location:
mauRepo/MolesManager/trunk/src/MolesManager
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/MolesManager/trunk/src/MolesManager/djencoder.py

    r8323 r8335  
    5151                #return {} 
    5252            else: 
    53                 self.__markers[id(value)] = value                 
     53                if isinstance(value, str) or isinstance(value, unicode):                     
     54                    self.__markers[id(value)] = self.escapeForJSON(value) 
     55                else: 
     56                    self.__markers[id(value)] = value 
    5457        return d 
    5558     
    56     @classmethod 
    5759    def escapeForJSON(self, toEscape): 
     60        res = toEscape.replace('"', '"') 
    5861        res = toEscape.replace("'", "'") 
    59         #res = res.replace('"', '\\"') 
    60         res = res.replace('\\', '\\\\') 
     62        res = res.replace('\\', '\\') 
    6163        return res 
    6264         
  • mauRepo/MolesManager/trunk/src/MolesManager/views/cedaObservationView.py

    r8325 r8335  
    3131    c = {} 
    3232    if record: 
    33         c['coObs'] = mark_safe(DJEncoder().escapeForJSON(DJEncoder().encode(record))) 
     33        c['coObs'] = mark_safe(DJEncoder().encode(record)) 
    3434        guid = request.moles3EPB.retrieveGUIDFromInstance(record) 
    3535        if guid: 
Note: See TracChangeset for help on using the changeset viewer.