示例#1
2
文件: top_wdg.py 项目: blezek/TACTIC
    def get_display(my):

        web = WebContainer.get_web()
        context_url = web.get_context_url().to_string()
        js_url = "%s/javascript" % context_url
        spt_js_url = "%s/spt_js" % context_url    # adding new core "spt" javascript library folder

        version = Environment.get_release_version()

        # add some third party libraries
        third_party = js_includes.third_party
        security = Environment.get_security()

        # FIXME: this logic should not be located here.
        # no reason to have the edit_area_full.js
        if not security.check_access("builtin", "view_script_editor", "allow") and security.check_access("builtin", "view_site_admin", "allow"):
            if "edit_area/edit_area_full.js" in third_party:
                third_party.remove("edit_area/edit_area_full.js")


        for include in js_includes.third_party:
            Container.append_seq("Page:js", "%s/%s" % (spt_js_url,include))

        all_js_path = js_includes.get_compact_js_filepath()

        if os.path.exists( all_js_path ):
            Container.append_seq("Page:js", "%s/%s" % (context_url, js_includes.get_compact_js_context_path_suffix()))
        else:
            for include in js_includes.legacy_core:
                Container.append_seq("Page:js", "%s/%s" % (js_url,include))

            for include in js_includes.spt_js:
                Container.append_seq("Page:js", "%s/%s" % (spt_js_url,include))

            for include in js_includes.legacy_app:
                Container.append_seq("Page:js", "%s/%s" % (js_url,include))


        #Container.append_seq("Page:js", "http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject.js")
        #Container.append_seq("Page:js", "/context/spt_js/UnityObject.js")


        #widget = DivWdg()
        #widget.set_id("javascript")
        #my.set_as_panel(widget)
        widget = Widget()

        js_files = Container.get("Page:js")
        for js_file in js_files:
            widget.add('<script src="%s?ver=%s" ></script>\n' % (js_file,version) )


        return widget
示例#2
0
    def add_internal_config(cls, configs, views):
        '''add an internal config based on project base type'''
        project = Project.get()
        project_type = project.get_base_type()
        # catch potential invalid xpath error
        try:
            if project_type:
                tmp_path = __file__
                dir_name = os.path.dirname(tmp_path)
                file_path = "%s/../config/%s-conf.xml" % (dir_name,
                                                          project_type)
                if os.path.exists(file_path):
                    for view in views:
                        config = WidgetConfig.get(file_path=file_path,
                                                  view=view)
                        if config.get_view_node():
                            configs.append(config)

            # finally, just look at the DEFAULT config
            tmp_path = __file__
            dir_name = os.path.dirname(tmp_path)
            file_path = "%s/../config/%s-conf.xml" % (dir_name, "DEFAULT")

            if os.path.exists(file_path):
                for view in views:
                    config = WidgetConfig.get(file_path=file_path, view=view)
                    if config.get_view_node():
                        configs.append(config)

        except XmlException as e:
            msg = "Error with view [%s]" % ' '.join(views)
            error_list = Container.get_seq(cls.ERR_MSG)
            if msg not in error_list:
                Container.append_seq(cls.ERR_MSG, msg)
                print(e.__str__())
示例#3
0
    def add_internal_config(cls, configs, views):
        '''add an internal config based on project base type'''
        project = Project.get()
        project_type = project.get_base_type()
        # catch potential invalid xpath error
        try:
            if project_type:
                tmp_path = __file__
                dir_name = os.path.dirname(tmp_path)
                file_path="%s/../config/%s-conf.xml" % (dir_name, project_type)
                if os.path.exists(file_path):
                    for view in views:
                        config = WidgetConfig.get(file_path=file_path, view=view)
                        if config.get_view_node():
                            configs.append(config)

            # finally, just look at the DEFAULT config
            tmp_path = __file__
            dir_name = os.path.dirname(tmp_path)
            file_path="%s/../config/%s-conf.xml" % (dir_name, "DEFAULT")
                
            if os.path.exists(file_path):
                for view in views:
                    config = WidgetConfig.get(file_path=file_path, view=view)
                    if config.get_view_node():
                        configs.append(config)

        except XmlException, e:
            msg = "Error with view [%s]"% ' '.join(views)
            error_list = Container.get_seq(cls.ERR_MSG)
            if msg not in error_list:
                Container.append_seq(cls.ERR_MSG, msg)
                print e.__str__()
示例#4
0
    def get_css_wdg(my):

        widget = Widget()

        web = WebContainer.get_web()
        context_url = web.get_context_url().to_string()

        skin = web.get_skin()

        # first load context css
        Container.append_seq("Page:css", "%s/style/layout.css" % context_url)


        # add the color wheel css
        Container.append_seq("Page:css", "%s/spt_js/mooRainbow/Assets/mooRainbow.css" % context_url)
        Container.append_seq("Page:css", "%s/spt_js/mooDialog/css/MooDialog.css" % context_url)
        Container.append_seq("Page:css", "%s/spt_js/mooScrollable/Scrollable.css" % context_url)

        # TEST
        Container.append_seq("Page:css", "%s/spt_js/video/video-js.css" % context_url)


        # get all of the registered css file
        css_files = Container.get_seq("Page:css")
        for css_file in css_files:
            widget.add('<link rel="stylesheet" href="%s" type="text/css" />\n' % css_file )

       
        return widget
示例#5
0
    def get_display(my):

        web = WebContainer.get_web()
        context_url = web.get_context_url().to_string()
        js_url = "%s/javascript" % context_url
        spt_js_url = "%s/spt_js" % context_url    # adding new core "spt" javascript library folder

        version = Environment.get_release_version()

        # add some third party libraries
        third_party = js_includes.third_party
        security = Environment.get_security()

        # FIXME: this logic should not be located here.
        # no reason to have the edit_area_full.js
        #if not security.check_access("builtin", "view_script_editor", "allow") and security.check_access("builtin", "view_site_admin", "allow"):
        #    if "edit_area/edit_area_full.js" in third_party:
        #        third_party.remove("edit_area/edit_area_full.js")


        for include in js_includes.third_party:
            Container.append_seq("Page:js", "%s/%s" % (spt_js_url,include))

        all_js_path = js_includes.get_compact_js_filepath()

        if os.path.exists( all_js_path ):
            Container.append_seq("Page:js", "%s/%s" % (context_url, js_includes.get_compact_js_context_path_suffix()))
        else:
            for include in js_includes.legacy_core:
                Container.append_seq("Page:js", "%s/%s" % (js_url,include))

            for include in js_includes.spt_js:
                Container.append_seq("Page:js", "%s/%s" % (spt_js_url,include))

            for include in js_includes.legacy_app:
                Container.append_seq("Page:js", "%s/%s" % (js_url,include))


        #Container.append_seq("Page:js", "http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject.js")
        #Container.append_seq("Page:js", "/context/spt_js/UnityObject.js")


        widget = Widget()

        js_files = Container.get("Page:js")
        for js_file in js_files:
            widget.add('<script src="%s?ver=%s" ></script>\n' % (js_file,version) )


        return widget
示例#6
0
    def run_sql(my, sql):
        ''' run an sql statement. my is an instance of the dynamically created 
        <project_type>Upgrade class. If SqlException arise, it will record the
        error, and the user is advised to check if the error is a result of syntax 
        error or the upgrade function is doing redundant work'''
        project = Project.get_by_code(my.project_code)
        db_resource = project.get_project_db_resource()
        db = DbContainer.get(db_resource)
        #if not my.quiet:
        #    print sql
        try:
            db.do_update(sql, quiet=my.quiet)
        except SqlException, e:
            print "Error: ", e
            # TEST for Sqlite
            if str(e).startswith("duplicate column name:"):
                pass
            elif str(e).startswith("table") and str(e).endswith(
                    "already exists"):
                pass

            elif not my.quiet:
                print
                print "WARNING: Skipping due to SqlException..."
                print "Message: ", e
                print
            members = inspect.getmembers(my, predicate=inspect.ismethod)
            key = '%s|%s' % (my.project_code, my.upgrade_class)

            Container.append_seq(key, (my.upgrade_method, str(e)))
            """  
            for name, member in members:
                # there should only be 1 upgrade method
                if name.startswith('upgrade_v'):       
                    Container.append_seq(key, (my.upgrade_method, str(e)))
                    break
            """
            # to prevent sql error affecting query that follows the Upgrade
            #DbContainer.abort_thread_sql()
            DbContainer.release_thread_sql()
示例#7
0
    def run_sql(my, sql):
        ''' run an sql statement. my is an instance of the dynamically created 
        <project_type>Upgrade class. If SqlException arise, it will record the
        error, and the user is advised to check if the error is a result of syntax 
        error or the upgrade function is doing redundant work'''
        project = Project.get_by_code(my.project_code)
        db_resource = project.get_project_db_resource()
        db = DbContainer.get(db_resource)
        #if not my.quiet:
        #    print sql
        try:
            db.do_update(sql, quiet=my.quiet)
        except SqlException, e:
            print "Error: ", e
            # TEST for Sqlite
            if str(e).startswith("duplicate column name:"):
                pass
            elif str(e).startswith("table") and str(e).endswith("already exists"):
                pass

            elif not my.quiet:
                print
                print "WARNING: Skipping due to SqlException..."
                print "Message: ", e
                print
            members = inspect.getmembers(my, predicate=inspect.ismethod)
            key = '%s|%s' %(my.project_code, my.upgrade_class)
            
            Container.append_seq(key, (my.upgrade_method, str(e)))
            """  
            for name, member in members:
                # there should only be 1 upgrade method
                if name.startswith('upgrade_v'):       
                    Container.append_seq(key, (my.upgrade_method, str(e)))
                    break
            """          
            # to prevent sql error affecting query that follows the Upgrade
            #DbContainer.abort_thread_sql()
            DbContainer.release_thread_sql()
示例#8
0
文件: top_wdg.py 项目: mwx1993/TACTIC
    def get_display(my):

        web = WebContainer.get_web()
        context_url = web.get_context_url().to_string()
        js_url = "%s/javascript" % context_url
        spt_js_url = "%s/spt_js" % context_url  # adding new core "spt" javascript library folder

        version = Environment.get_release_version()

        # add some third party libraries
        third_party = js_includes.third_party
        security = Environment.get_security()

        for include in js_includes.third_party:
            Container.append_seq("Page:js", "%s/%s" % (spt_js_url, include))

        all_js_path = js_includes.get_compact_js_filepath()

        if os.path.exists(all_js_path):
            Container.append_seq(
                "Page:js",
                "%s/%s" % (context_url,
                           js_includes.get_compact_js_context_path_suffix()))
        else:
            for include in js_includes.legacy_core:
                Container.append_seq("Page:js", "%s/%s" % (js_url, include))

            for include in js_includes.spt_js:
                Container.append_seq("Page:js",
                                     "%s/%s" % (spt_js_url, include))

            for include in js_includes.legacy_app:
                Container.append_seq("Page:js", "%s/%s" % (js_url, include))

        # custom js files to include
        includes = Config.get_value("install", "include_js")
        includes = includes.split(",")
        for include in includes:
            include = include.strip()
            if include:
                print "include: ", include
                Container.append_seq("Page:js", include)

        widget = Widget()

        js_files = Container.get("Page:js")
        for js_file in js_files:
            widget.add('<script src="%s?ver=%s" ></script>\n' %
                       (js_file, version))

        return widget
示例#9
0
    def get_css_wdg(my):

        widget = Widget()

        web = WebContainer.get_web()
        context_url = web.get_context_url().to_string()

        skin = web.get_skin()

        # Bootstrap
        use_bootstrap = True
        if use_bootstrap:
            Container.append_seq(
                "Page:css",
                "%s/spt_js/bootstrap/css/bootstrap.min.css" % context_url)

        # add the color wheel css
        Container.append_seq(
            "Page:css",
            "%s/spt_js/mooRainbow/Assets/mooRainbow.css" % context_url)
        Container.append_seq(
            "Page:css", "%s/spt_js/mooDialog/css/MooDialog.css" % context_url)
        Container.append_seq(
            "Page:css", "%s/spt_js/mooScrollable/Scrollable.css" % context_url)

        # first load context css
        Container.append_seq("Page:css", "%s/style/layout.css" % context_url)

        # TEST
        Container.append_seq("Page:css",
                             "%s/spt_js/video/video-js.css" % context_url)

        # get all of the registered css file
        css_files = Container.get_seq("Page:css")
        for css_file in css_files:
            widget.add(
                '<link rel="stylesheet" href="%s" type="text/css" />\n' %
                css_file)

        # custom js files to include
        includes = Config.get_value("install", "include_css")
        includes = includes.split(",")
        for include in includes:
            include = include.strip()
            if include:
                print "include: ", include
                widget.add(
                    '<link rel="stylesheet" href="%s" type="text/css" />\n' %
                    include)

        return widget
示例#10
0
文件: top_wdg.py 项目: asmboom/TACTIC
    def get_display(my):

        web = WebContainer.get_web()
        context_url = web.get_context_url().to_string()
        js_url = "%s/javascript" % context_url
        spt_js_url = "%s/spt_js" % context_url    # adding new core "spt" javascript library folder

        version = Environment.get_release_version()

        # add some third party libraries
        third_party = js_includes.third_party
        security = Environment.get_security()


        for include in js_includes.third_party:
            Container.append_seq("Page:js", "%s/%s" % (spt_js_url,include))

        all_js_path = js_includes.get_compact_js_filepath()

        if os.path.exists( all_js_path ):
            Container.append_seq("Page:js", "%s/%s" % (context_url, js_includes.get_compact_js_context_path_suffix()))
        else:
            for include in js_includes.legacy_core:
                Container.append_seq("Page:js", "%s/%s" % (js_url,include))

            for include in js_includes.spt_js:
                Container.append_seq("Page:js", "%s/%s" % (spt_js_url,include))

            for include in js_includes.legacy_app:
                Container.append_seq("Page:js", "%s/%s" % (js_url,include))


        # custom js files to include
        includes = Config.get_value("install", "include_js")
        includes = includes.split(",")
        for include in includes:
            include = include.strip()
            if include:
                print "include: ", include
                Container.append_seq("Page:js", include)


        widget = Widget()

        js_files = Container.get("Page:js")
        for js_file in js_files:
            widget.add('<script src="%s?ver=%s" ></script>\n' % (js_file,version) )


        return widget
示例#11
0
文件: top_wdg.py 项目: asmboom/TACTIC
    def get_css_wdg(my):

        widget = Widget()

        web = WebContainer.get_web()
        context_url = web.get_context_url().to_string()

        skin = web.get_skin()


        # Bootstrap
        use_bootstrap = True
        if use_bootstrap:
            Container.append_seq("Page:css", "%s/spt_js/bootstrap/css/bootstrap.min.css" % context_url)



        # add the color wheel css
        Container.append_seq("Page:css", "%s/spt_js/mooRainbow/Assets/mooRainbow.css" % context_url)
        Container.append_seq("Page:css", "%s/spt_js/mooDialog/css/MooDialog.css" % context_url)
        Container.append_seq("Page:css", "%s/spt_js/mooScrollable/Scrollable.css" % context_url)

        # first load context css
        Container.append_seq("Page:css", "%s/style/layout.css" % context_url)



        # TEST
        Container.append_seq("Page:css", "%s/spt_js/video/video-js.css" % context_url)


        # get all of the registered css file
        css_files = Container.get_seq("Page:css")
        for css_file in css_files:
            widget.add('<link rel="stylesheet" href="%s" type="text/css" />\n' % css_file )

        # custom js files to include
        includes = Config.get_value("install", "include_css")
        includes = includes.split(",")
        for include in includes:
            include = include.strip()
            if include:
                print "include: ", include
                widget.add('<link rel="stylesheet" href="%s" type="text/css" />\n' % include )

        return widget
示例#12
0
 def add_outdated_ref(version_wdg):
     Container.append_seq('SubRef_outdated', version_wdg)
示例#13
0
 def add_outdated_ref(version_wdg):
     Container.append_seq('SubRef_outdated', version_wdg)