Exemplo n.º 1
0
class Index(AppServer):

    def get_page_widget(self):
        return IndexWdg()

    def get_top_wdg(self):
        from tactic.ui.app import TopWdg
        self.top = TopWdg()
        body = self.top.get_body()
        body.add_class("body_login")
        return self.top
Exemplo n.º 2
0
 def get_top_wdg(self):
     from tactic.ui.app import TopWdg
     self.top = TopWdg()
     body = self.top.get_body()
     body.add_class("body_login")
     return self.top
Exemplo n.º 3
0
 def get_top_wdg(my):
     from tactic.ui.app import TopWdg
     my.top = TopWdg()
     body = my.top.get_body()
     body.add_class("body_login")
     return my.top
Exemplo n.º 4
0
 def get_top_wdg(my):
     from tactic.ui.app import TopWdg
     my.top = TopWdg()
     return my.top
Exemplo n.º 5
0
 def get_top_wdg(self):
     from tactic.ui.app import TopWdg
     self.top = TopWdg()
     return self.top
Exemplo n.º 6
0
    def get_top_wdg(self):
        ''' A custom widget can replace TopWdg per custom URL or per project.
         1. If a custom url specifies a top class through the top_wdg_cls attribute, 
            then this class is used.
         2. If no custom url is specified, and a project top class is specified
            through the ProjectSetting key top_wdg_cls, this class is used 
            except for TACTIC admin pages.
         3. The default widget used is tactic.ui.app.TopWdg.'''

        top_wdg_cls = None

        if not self.hash and not self.custom_url:
            search = Search("config/url")
            search.add_filter("url", "/index")
            self.custom_url = search.get_sobject()

        # TEST Using X-SendFile
        #if self.hash and self.hash[0] == 'ASSETS':
        #    self.top = XSendFileTopWdg(hash=self.hash)
        #    return self.top

        # REST API
        if self.hash and self.hash[0] == 'REST':
            handler = 'tactic.protocol.APIRestHandler'
            hash = "/".join(self.hash)
            hash = "/%s" % hash
            self.top = CustomTopWdg(url=self.custom_url,
                                    hash=hash,
                                    handler=handler)
            return self.top

        if self.custom_url:
            xml = self.custom_url.get_xml_value("widget")
            index = xml.get_value("element/@index")
            admin = xml.get_value("element/@admin")
            top_wdg_cls = xml.get_value("element/@top_wdg_cls")
            widget = xml.get_value("element/@widget")
            bootstrap = xml.get_value("element/@bootstrap")
            if index == 'true' or admin == 'true':
                pass
            elif bootstrap == 'true':
                widget = BootstrapIndexWdg()
                return widget
            elif widget == 'true':
                hash = "/".join(self.hash)
                hash = "/%s" % hash
                self.top = CustomTopWdg(url=self.custom_url, hash=hash)
                return self.top

        if not top_wdg_cls:
            if self.hash and self.hash[0] == "admin":
                pass
            else:
                from pyasm.biz import ProjectSetting
                top_wdg_cls = ProjectSetting.get_value_by_key("top_wdg_cls")

        if top_wdg_cls:
            self.top = Common.create_from_class_path(top_wdg_cls, {},
                                                     {'hash': self.hash})
        else:
            from tactic.ui.app import TopWdg
            self.top = TopWdg(hash=self.hash)

        return self.top