optimization

master
inpos 2018-08-08 22:41:00 +03:00
parent feebd05e99
commit 3ec9cdcfab
2 changed files with 2 additions and 43 deletions

View File

@ -20,7 +20,6 @@ class MyApplication(cp.ExtApplication):
{'text': 'Close', 'handler': js.function('this.up(\'window\').close()')}]}) {'text': 'Close', 'handler': js.function('this.up(\'window\').close()')}]})
wnd.show() wnd.show()
wnd.setHeight(200) wnd.setHeight(200)
print(repr(js.live_methods))
cp.THEME = 'classic' cp.THEME = 'classic'

View File

@ -14,48 +14,10 @@ class FuncWithParams:
self.params = params self.params = params
def list2extjs(l): def list2extjs(l):
s = '[ %s ]' return '[ %s ]' % ', '.join([encode(v) for v in l])
ss = []
for v in l:
if isinstance(v, int):
ss.append('%d' % v)
elif isinstance(v, str):
ss.append('\'%s\'' % v)
elif isinstance(v, types.FunctionType):
ss.append(str(function(js_ajax(v))))
elif isinstance(v, FuncWithParams):
ss.append(str(function(js_ajax(v.func, v.params))))
elif isinstance(v, JsFunction):
ss.append(str(v))
elif isinstance(v, JsNode):
ss.append(str(v))
elif isinstance(v, dict):
ss.append(dict2extjs(v))
elif isinstance(v, (list, tuple)):
ss.append(list2extjs(v))
return s % ', '.join(ss)
def dict2extjs(d): def dict2extjs(d):
s = '{ %s }' return '{ %s }' % ', '.join('%s: %s' % (k, encode(v)) for k,v in d.items())
ss = []
for k, v in d.items():
if isinstance(v, int):
ss.append('%s: %d' % (k,v))
elif isinstance(v, str):
ss.append('%s: \'%s\'' % (k, v))
elif isinstance(v, types.FunctionType):
ss.append('%s: %s' % (k, str(function(js_ajax(v)))))
elif isinstance(v, FuncWithParams):
ss.append('%s: %s' % (k, str(function(js_ajax(v.func, v.params)))))
elif isinstance(v, JsFunction):
ss.append('%s: %s' % (k, str(v)))
elif isinstance(v, JsNode):
ss.append('%s: %s' % (k, str(v)))
elif isinstance(v, dict):
ss.append('%s: %s' % (k, dict2extjs(v)))
elif isinstance(v, (list, tuple)):
ss.append('%s: %s' % (k, list2extjs(v)))
return s % ', '.join(ss)
def encode(o): def encode(o):
@ -73,8 +35,6 @@ def encode(o):
return str(function(js_ajax(o.func, o.params))) return str(function(js_ajax(o.func, o.params)))
elif isinstance(o, JsFunction): elif isinstance(o, JsFunction):
return str(o) return str(o)
elif isinstance(o, JsNode):
return str(o)
elif isinstance(o, dict): elif isinstance(o, dict):
return dict2extjs(o) return dict2extjs(o)
else: else: