cherryext/orun/extjs/cp.py

38 lines
1.0 KiB
Python
Raw Normal View History

2013-04-30 09:49:34 +04:00
import os
from orun.extjs import *
from orun.servers import cp
2018-08-08 10:08:17 +03:00
import cherrypy
THEME = 'gray'
@cherrypy.expose
class ExtJS(object):
_cp_config = {
'tools.staticdir.on': True,
'tools.staticdir.dir': os.path.join(os.path.dirname(__file__), 'static/','ext-4.2.1'),
}
2013-04-30 09:49:34 +04:00
class ExtApplication(cp.Application):
2018-08-08 10:08:17 +03:00
def __init__(self, title=''):
super(ExtApplication, self).__init__(title)
self.ext_421 = ExtJS()
2013-04-30 09:49:34 +04:00
def index(self, *args, **kwargs):
f = open(os.path.join(os.path.dirname(__file__), 'app.html')).read()
self.main()
2018-08-08 10:08:17 +03:00
return f % (self.title, THEME, THEME, str(js.js_manager))
2013-04-30 09:49:34 +04:00
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()