Changeset 327 in main


Ignore:
Timestamp:
09/22/11 14:47:29 (8 years ago)
Author:
pcosquer
Message:

navigate: fix bug with non ascii string

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/openPLM/plmapp/navigate.py

    r314 r327  
    4444OSR = "only_search_results" 
    4545 
    46 def encode(s): 
    47     return s.encode("utf-8") 
    48  
    4946def get_path(obj): 
    5047    if hasattr(obj, "type"): 
    51         return "/".join(map(encode, (obj.type, obj.reference, obj.revision))) 
     48        return "/".join((obj.type, obj.reference, obj.revision)) 
    5249    else: 
    5350        return obj.username 
     
    6764    def write(self, path): 
    6865        if hasattr(path, "write"): 
    69             path.write(self.data) 
     66            path.write(self.data.encode("utf-8")) 
    7067        else: 
    7168            with file(path, "w") as f: 
     
    305302                node.attr["tooltip"] = s + str(obj.id) 
    306303        else: 
    307             node.attr["label"] = encode(obj.username) 
    308         node.attr["label"] += "\\n" + encode(extra_label) 
     304            node.attr["label"] = obj.username 
     305        node.attr["label"] += "\\n" + extra_label 
    309306        t = type_.__name__.replace("Controller", "") 
    310307        node.attr["id"] = "_".join((str(obj_id or obj.id), t, str(obj.id))) 
     
    358355        edges = self.graph.edges() 
    359356        self.graph.remove_edges_from(edges) 
    360         s = str(self.graph) 
     357        s = unicode(self.graph) 
    361358        s = s[:s.rfind("}")] 
    362359        edges.sort() 
    363         s += "\n".join("%s -> %s;" % (a,b) for a, b in edges) + "}\n" 
     360        s += "\n".join(u"%s -> %s;" % (a,b) for a, b in edges) + "}\n" 
    364361        self.graph.close() 
    365362        self.graph = FrozenAGraph(s) 
Note: See TracChangeset for help on using the changeset viewer.