uilib.py
changeset 10703 3cb87b61b067
parent 10702 f94c812c3669
child 10784 21bb9a00adeb
equal deleted inserted replaced
10702:f94c812c3669 10703:3cb87b61b067
   338         self.parent = parent
   338         self.parent = parent
   339     def __unicode__(self):
   339     def __unicode__(self):
   340         if self.parent:
   340         if self.parent:
   341             return u'%s.%s' % (self.parent, self.id)
   341             return u'%s.%s' % (self.parent, self.id)
   342         return text_type(self.id)
   342         return text_type(self.id)
   343     def __str__(self):
   343     __str__ = __unicode__ if PY3 else lambda self: self.__unicode__().encode('utf-8')
   344         return text_type(self).encode('utf8')
       
   345     def __getattr__(self, attr):
   344     def __getattr__(self, attr):
   346         return _JSId(attr, self)
   345         return _JSId(attr, self)
   347     def __call__(self, *args):
   346     def __call__(self, *args):
   348         return _JSCallArgs(args, self)
   347         return _JSCallArgs(args, self)
   349 
   348 
   357         for arg in self.args:
   356         for arg in self.args:
   358             args.append(js_dumps(arg))
   357             args.append(js_dumps(arg))
   359         if self.parent:
   358         if self.parent:
   360             return u'%s(%s)' % (self.parent, ','.join(args))
   359             return u'%s(%s)' % (self.parent, ','.join(args))
   361         return ','.join(args)
   360         return ','.join(args)
       
   361     __str__ = __unicode__ if PY3 else lambda self: self.__unicode__().encode('utf-8')
   362 
   362 
   363 class _JS(object):
   363 class _JS(object):
   364     def __getattr__(self, attr):
   364     def __getattr__(self, attr):
   365         return _JSId(attr)
   365         return _JSId(attr)
   366 
   366