示例#1
0
    def get(self, filter_params):
        res_list = []
        try:
            get_list = getattr(self.model, model_fn(self, 'get_list'))
            res_list = get_list(*self.model_args)
        except AttributeError:
            pass

        return template.render(get_class_name(self), res_list)
示例#2
0
 def default(self, page, **kwargs):
     if page.endswith('.html'):
         return template.render(page, kwargs)
     if page.endswith('.json'):
         cherrypy.response.headers['Content-Type'] = \
             'application/json;charset=utf-8'
         context = template.render_cheetah_file(page, None)
         return context.encode("utf-8")
     raise cherrypy.HTTPError(404)
示例#3
0
 def default(self, page, **kwargs):
     if page.endswith('.html'):
         return template.render(page, kwargs)
     if page.endswith('.json'):
         cherrypy.response.headers['Content-Type'] = \
             'application/json;charset=utf-8'
         context = template.render_cheetah_file(page, None)
         return context.encode("utf-8")
     raise cherrypy.HTTPError(404)
示例#4
0
    def error_production_handler(self, status, message, traceback, version):
        self._set_CSP()

        data = {'code': status, 'reason': message}
        res = template.render('error.html', data)

        if (type(res) is unicode and
                LooseVersion(cherrypy.__version__) < LooseVersion('3.2.5')):
            res = res.encode("utf-8")
        return res
示例#5
0
文件: root.py 项目: Seccion7/dep-wok
 def default(self, page, **kwargs):
     kwargs['scripts'] = self._get_scripts(page)
     if page.endswith('.html'):
         return template.render(page, kwargs)
     if page.endswith('.json'):
         content_type = 'application/json;charset=utf-8'
         cherrypy.response.headers['Content-Type'] = content_type
         context = template.render_cheetah_file(page, None)
         return context.encode('utf-8')
     raise cherrypy.HTTPError(404)
示例#6
0
    def error_production_handler(self, status, message, traceback, version):
        self._set_CSP()

        data = {'code': status, 'reason': message}
        res = template.render('error.html', data)

        if (type(res) is unicode and
                LooseVersion(cherrypy.__version__) < LooseVersion('3.2.5')):
            res = res.encode("utf-8")
        return res
示例#7
0
    def error_development_handler(self, status, message, traceback, version):
        self._set_CSP()

        data = {'code': status, 'reason': message,
                'call_stack': cherrypy._cperror.format_exc()}
        res = template.render('error.html', data)

        if (type(res) is unicode and
                LooseVersion(cherrypy.__version__) < LooseVersion('3.2.5')):
            res = res.encode("utf-8")
        return res
示例#8
0
文件: root.py 项目: lcorreia/wok
    def error_development_handler(self, status, message, traceback, version):
        self._set_CSP()

        data = {'code': status, 'reason': message,
                'call_stack': cherrypy._cperror.format_exc()}
        res = template.render('error.html', data)

        if (type(res) is unicode and
                LooseVersion(cherrypy.__version__) < LooseVersion('3.2.5')):
            res = res.encode("utf-8")
        return res
示例#9
0
    def tabs(self, page, **kwargs):
        # In order to load the Guests tab, we also use Cheetah in the tab
        # template to save the delay of the extra get to the guest page
        # For that, the tab template needs to know the correct path to ui files
        data = {}
        data['ui_dir'] = paths.ui_dir

        if page.endswith('.html'):
            context = template.render('tabs/' + page, data)
            cherrypy.response.cookie["lastPage"] = "/#tabs/" + page[:-5]
            cherrypy.response.cookie['lastPage']['path'] = '/'
            return context
        raise cherrypy.HTTPError(404)
示例#10
0
    def tabs(self, page, **kwargs):
        # In order to load the Guests tab, we also use Cheetah in the tab
        # template to save the delay of the extra get to the guest page
        # For that, the tab template needs to know the correct path to ui files
        data = {}
        data['ui_dir'] = paths.ui_dir

        if page.endswith('.html'):
            context = template.render('tabs/' + page, data)
            cherrypy.response.cookie[
                "lastPage"] = "/#tabs/" + page[:-5]
            cherrypy.response.cookie['lastPage']['path'] = '/'
            return context
        raise cherrypy.HTTPError(404)
示例#11
0
文件: root.py 项目: www3838438/wok
    def tabs(self, page, **kwargs):
        # In order to load the Guests tab, we also use Cheetah in the tab
        # template to save the delay of the extra get to the guest page
        # For that, the tab template needs to know the correct path to ui files
        paths = cherrypy.request.app.root.paths
        script_name = cherrypy.request.app.script_name or "/"
        last_page = os.path.join(script_name, "tabs/", page[:-5]).lstrip("/")

        data = {}
        data['ui_dir'] = paths.ui_dir
        data['scripts'] = self._get_scripts(page)

        if page.endswith('.html'):
            context = template.render('/tabs/' + page, data)
            cherrypy.response.cookie["lastPage"] = "/#" + last_page
            cherrypy.response.cookie['lastPage']['path'] = '/'
            return context
        raise cherrypy.HTTPError(404)
示例#12
0
    def tabs(self, page, **kwargs):
        # In order to load the Guests tab, we also use Cheetah in the tab
        # template to save the delay of the extra get to the guest page
        # For that, the tab template needs to know the correct path to ui files
        paths = cherrypy.request.app.root.paths
        script_name = cherrypy.request.app.script_name
        last_page = script_name.lstrip("/") + "/tabs/" + page[:-5]

        data = {}
        data['ui_dir'] = paths.ui_dir

        data['scripts'] = []
        for plugin, app in cherrypy.tree.apps.iteritems():
                if app.root.extends is not None:
                    scripts = app.root.extends.get(script_name, {})
                    if page in scripts.keys():
                        data['scripts'].append(scripts[page])

        if page.endswith('.html'):
            context = template.render('/tabs/' + page, data)
            cherrypy.response.cookie["lastPage"] = "/#" + last_page
            cherrypy.response.cookie['lastPage']['path'] = '/'
            return context
        raise cherrypy.HTTPError(404)
示例#13
0
文件: root.py 项目: lcorreia/wok
    def tabs(self, page, **kwargs):
        # In order to load the Guests tab, we also use Cheetah in the tab
        # template to save the delay of the extra get to the guest page
        # For that, the tab template needs to know the correct path to ui files
        paths = cherrypy.request.app.root.paths
        script_name = cherrypy.request.app.script_name
        last_page = script_name.lstrip("/") + "/tabs/" + page[:-5]

        data = {}
        data['ui_dir'] = paths.ui_dir

        data['scripts'] = []
        for plugin, app in cherrypy.tree.apps.iteritems():
                if app.root.extends is not None:
                    scripts = app.root.extends.get(script_name, {})
                    if page in scripts.keys():
                        data['scripts'].append(scripts[page])

        if page.endswith('.html'):
            context = template.render('/tabs/' + page, data)
            cherrypy.response.cookie["lastPage"] = "/#" + last_page
            cherrypy.response.cookie['lastPage']['path'] = '/'
            return context
        raise cherrypy.HTTPError(404)
示例#14
0
 def get(self, filter_params):
     res_list = []
     get_list = getattr(self.model, model_fn(self, 'get_list'))
     res_list = get_list(*self.model_args, **filter_params)
     return template.render(get_class_name(self), res_list)
示例#15
0
 def get(self, filter_params):
     res_list = []
     get_list = getattr(self.model, model_fn(self, 'get_list'))
     res_list = get_list(*self.model_args, **filter_params)
     return template.render(get_class_name(self), res_list)