[uilib] js objects implements __unicode__
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 08 Jul 2010 20:18:53 +0200
changeset 5951 6026582ae4f1
parent 5950 f84dba9b8eca
child 5952 adb87a075281
[uilib] js objects implements __unicode__
uilib.py
--- a/uilib.py	Thu Jul 08 19:18:56 2010 +0200
+++ b/uilib.py	Thu Jul 08 20:18:53 2010 +0200
@@ -234,10 +234,12 @@
     def __init__(self, id, parent=None):
         self.id = id
         self.parent = parent
-    def __str__(self):
+    def __unicode__(self):
         if self.parent:
-            return '%s.%s' % (self.parent, self.id)
-        return '%s' % self.id
+            return u'%s.%s' % (self.parent, self.id)
+        return unicode(self.id)
+    def __str__(self):
+        return unicode(self).encode('utf8')
     def __getattr__(self, attr):
         return _JSId(attr, self)
     def __call__(self, *args):
@@ -248,10 +250,10 @@
         assert isinstance(args, tuple)
         self.args = args
         self.parent = parent
-    def __str__(self):
-        args = ','.join(json_dumps(arg) for arg in self.args)
+    def __unicode__(self):
+        args = u','.join(json_dumps(arg) for arg in self.args)
         if self.parent:
-            return '%s(%s)' % (self.parent, args)
+            return u'%s(%s)' % (self.parent, args)
         return args
 
 class _JS(object):