First commit
This commit is contained in:
commit
2909a53756
19 files changed
+448
No files matched your search
@@ -0,0 +1,5 @@
|
||||
|
||||
from orun import js
|
||||
from orun.js import client
|
||||
from . import base as Ext
|
||||
from .base import *
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>%s</title>
|
||||
<script src="http://cdn.sencha.com/ext/gpl/4.2.0/ext-all.js"></script>
|
||||
<link rel="stylesheet" href="http://cdn.sencha.com/ext/gpl/4.2.0/resources/ext-theme-classic/ext-theme-classic-all.css">
|
||||
<script>
|
||||
Ext.onReady(function () {
|
||||
%s
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
@@ -0,0 +1,56 @@
|
||||
|
||||
import json
|
||||
from . import js
|
||||
|
||||
__all__ = ['create', 'createByAlias', 'Component']
|
||||
|
||||
def js_ajax(fn):
|
||||
i = id(fn)
|
||||
js.live_methods[i] = fn
|
||||
return js.client.Ext.Ajax.request({'url': js.AJAX_URL, 'method': 'GET', 'params': {'fn': i, 'id': js.client.this.id}, 'success': js.function('eval(arguments[0].responseText);')})
|
||||
|
||||
js.js_ajax = js_ajax
|
||||
|
||||
def _create(meth, name, args):
|
||||
#args['pyLive'] = True : TODO
|
||||
obj = Component(**args)
|
||||
js.write('var %s = Ext.create("%s", %s);' % (obj._id, name, str(obj)))
|
||||
return obj
|
||||
|
||||
def create(name, args={}):
|
||||
return _create('create', name, args)
|
||||
|
||||
def createByAlias(alias, args={}):
|
||||
return _create('createByAlias', alias, args)
|
||||
|
||||
def get(id):
|
||||
return js.JsNode('Ext.get("%s")' % id)
|
||||
|
||||
def getCmp(id):
|
||||
return js.JsNode('Ext.getCmp("%s")' % id)
|
||||
|
||||
class Component(js.JsObject):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Component, self).__init__(*args, **kwargs)
|
||||
|
||||
def _update(self, config):
|
||||
def get_obj(value):
|
||||
if isinstance(value, dict):
|
||||
return Component(**v)
|
||||
elif isinstance(value, (list, tuple)):
|
||||
return [get_obj(v) for v in value]
|
||||
else:
|
||||
return value
|
||||
cfg = {}
|
||||
for k, v in config.items():
|
||||
cfg[k] = get_obj(v)
|
||||
super(Component, self).update(cfg)
|
||||
|
||||
def down(self, item):
|
||||
pass
|
||||
|
||||
def up(self, item):
|
||||
pass
|
||||
|
||||
def __str__(self):
|
||||
return json.dumps(self._js, default=js._encoder)
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
import os
|
||||
from orun.extjs import *
|
||||
from orun.servers import cp
|
||||
|
||||
class ExtApplication(cp.Application):
|
||||
def index(self, *args, **kwargs):
|
||||
f = open(os.path.join(os.path.dirname(__file__), 'app.html')).read()
|
||||
self.main()
|
||||
return f % (self.title, str(js.js_manager))
|
||||
index.exposed = True
|
||||
|
||||
def ajax_callback(self, *args, **kwargs):
|
||||
fn = kwargs.pop('fn')
|
||||
if fn:
|
||||
fn = js.live_methods[int(fn)]
|
||||
fn(*args, **kwargs)
|
||||
return str(js.js_manager)
|
||||
ajax_callback.exposed = True
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = ExtApplication('Orun (ExtJS Application)')
|
||||
app.run()
|
||||
Reference in new issue
Block a user