当前位置: 首页>>代码示例>>Python>>正文


Python Xml.set_attribute方法代码示例

本文整理汇总了Python中pyasm.common.Xml.set_attribute方法的典型用法代码示例。如果您正苦于以下问题:Python Xml.set_attribute方法的具体用法?Python Xml.set_attribute怎么用?Python Xml.set_attribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyasm.common.Xml的用法示例。


在下文中一共展示了Xml.set_attribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: execute

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import set_attribute [as 别名]
    def execute(my):
        database = "sthpw" 

        sql = DbContainer.get(database)
        value_array = sql.do_query("select code, cc from (select code, count(code) as cc from file group by code order by cc desc) as X where cc > 1;")
        #value_array = sql.do_query("select code, cc from (select code, count(code) as cc from file group by code order by cc desc) as X;")

        print "found [%s] pairs" % len(value_array)

        for count, value_list in enumerate(value_array):
            if count >= BATCH:
                break

            # get the file object
            file_code = value_list[0]
            search = Search("sthpw/file")
            search.add_filter("code", file_code)
            files = search.get_sobjects()

            #if len(files) == 1:
            #    continue

            for file in files:
                project_code = file.get_value("project_code")
                if not project_code:
                    print "WARNING: file [%s] has no project_code" % file_code
                    continue

                project = Project.get_by_code(project_code)
                initials = project.get_initials()

                id = file.get_id()
                new_file_code = "%s%s" % (id, initials)
                if file_code == new_file_code:
                    continue

                print "-"*20
                print "switching: ", file_code, "to", new_file_code


                snapshot_code = file.get_value("snapshot_code")
                snapshot = Snapshot.get_by_code(snapshot_code)
                assert snapshot

                snapshot_xml = snapshot.get_xml_value("snapshot")
                print snapshot_xml.to_string()
                node = snapshot_xml.get_node("snapshot/file[@file_code='%s']" % file_code)
                Xml.set_attribute(node, "file_code", new_file_code)
                print snapshot_xml.to_string()

                assert node


                # set the file_code
                file.set_value("code", new_file_code)
                file.commit()

                # set the snapshot
                snapshot.set_value("snapshot", snapshot_xml.to_string() )
                snapshot.commit()
开发者ID:0-T-0,项目名称:TACTIC,代码行数:62,代码来源:fix_duplicate_file_code.py

示例2: execute

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import set_attribute [as 别名]
    def execute(my):

        class_names = my.kwargs.get("class_names")
        attrs_list = my.kwargs.get("attrs_list")
        kwargs_list = my.kwargs.get("kwargs_list")

        xml = Xml()
        xml.create_doc("config")
        root = xml.get_root_node()

        view = xml.create_element("tab")
        xml.append_child(root, view)

        for class_name, attrs, kwargs in zip(class_names, attrs_list, kwargs_list):

            element = xml.create_element("element")
            xml.append_child(view, element)

            for key, value in attrs.items():
                xml.set_attribute(element, key, value)

            display = xml.create_element("display")
            xml.append_child(element, display)

            xml.set_attribute(display, "class", class_name)

            for key, value in kwargs.items():
                attr = xml.create_text_element(key, value, node=display)
                xml.append_child(display, attr)

        xml_string = xml.to_string()

        from pyasm.web import WidgetSettings
        WidgetSettings.set_value_by_key("tab", xml_string)
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:36,代码来源:page_nav_container_wdg.py

示例3: handle_config

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import set_attribute [as 别名]
    def handle_config(my):
        web = WebContainer.get_web()

        search_type = my.kwargs.get("search_type")
        view = my.view
        config_search_type = "config/widget_config"
        
        search = Search(config_search_type)
        search.add_filter("search_type", search_type)
        search.add_filter("view", view)
        search.add_filter("login", my.login)
        config = search.get_sobject()
        if not config:
            config = SearchType.create(config_search_type)
            config.set_value("search_type", search_type )
            config.set_value("view", view )
            if my.login:
                 config.set_value("login", my.login )
            xml = config.get_xml_value("config", "config")
            root = xml.get_root_node()
            # reinitialize
            config._init()

            # build a new config
            view_node = xml.create_element(view)
            root.appendChild(view_node)

        config_mode = web.get_form_value("config_mode")
        if config_mode == "advanced":
            config_string = web.get_form_value("config_xml")
        else:
            config_title = web.get_form_value("config_title")
            config_icon = web.get_form_value("config_icon")
            config_icon2 = web.get_form_value("config_icon2")
            if config_icon2:
                config_icon = config_icon2

            # TAKEN FROM API: should be centralized or something
            from tactic.ui.panel import SideBarBookmarkMenuWdg
            config_view = SideBarBookmarkMenuWdg.get_config(search_type, view)
            node = config_view.get_element_node(my.element_name)
            if node:
                config_xml = config_view.get_xml()

                node = config_view.get_element_node(my.element_name)
                Xml.set_attribute(node, "title", config_title)
                Xml.set_attribute(node, "icon", config_icon)

                config_string = config_xml.to_string(node)
            else:
                config_string = '''
                <element name="%s" title="%s" icon="%s"/>
                ''' %(my.element_name, config_title, config_icon)

        config.append_xml_element(my.element_name, config_string)
        config.commit_config()
开发者ID:blezek,项目名称:TACTIC,代码行数:58,代码来源:view_manager_wdg.py

示例4: get_by_code

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import set_attribute [as 别名]
    def get_by_code(cls, code, allow_default=False):
        '''it is fatal not to have a pipeline, so put a default'''
        if not code:
            return None

        # first look at project specific pipeline
        pipeline = Search.get_by_code("config/pipeline", code)

        if not pipeline:
            pipeline = super(Pipeline,cls).get_by_code(code)

        if not pipeline and code == 'task':
            # Create a default task pipeline
            pipeline = SearchType.create("sthpw/pipeline")
            pipeline.set_value("code", "task")
            from pyasm.biz import Task
            xml = Task.get_default_task_xml()
            pipeline.set_value("pipeline", xml)
            pipeline.set_pipeline(xml)
            pipeline.set_value("search_type", "sthpw/task")
            #pipeline.commit()


        if not pipeline and allow_default:
            search = Search(cls)
            search.add_filter('code', 'default')
            pipeline = search.get_sobject()
            if not pipeline:
                
                pipeline = cls.create('default',  \
                    'default pipeline', '')

                xml = pipeline.get_xml_value("pipeline")

                # create a default process for the table
                root = xml.get_root_node()
                element = xml.create_element("process")
                Xml.set_attribute(element,"name", "default_process")
                Xml.append_child(root, element)

                pipeline.set_value('pipeline', xml.get_xml())
                pipeline.commit()
                
                # set the pipeline
                pipeline.set_pipeline(pipeline.get_value('pipeline'))
                Environment.add_warning("pipeline autogenerated", \
                    "[default] pipeline has just been created.")
        # Sometimes, a pipeline is instantiated without calling set_pipeline()
        # to be looked into
        if pipeline and not pipeline.get_processes():
            pipeline.set_pipeline(pipeline.get_value('pipeline'))
        return pipeline
开发者ID:funic,项目名称:TACTIC,代码行数:54,代码来源:pipeline.py

示例5: handle_columns_mode

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import set_attribute [as 别名]
    def handle_columns_mode(my):

        doc = my.xml.create_doc("config")
        root = my.xml.get_root_node()
        
        columns = my.get_columns()
        if len(columns) == 1 and columns[0] == "id":
            columns = my.get_columns(required_only=False)

        # create the table
        # search is a special view for SearchWdg and it should not be created
        if my.view not in ['search','publish']:
            if my.view.find('@') != -1:
                table = my.xml.create_element('view', attrs={'name': my.view})
            else:
                table = my.xml.create_element(my.view)
            my.xml.append_child(root, table)
            for column in columns:
                if column in ["_id", "id", "oid", "s_status"]:
                    continue
                element = my.xml.create_element("element")
                Xml.set_attribute(element, "name", column)
                my.xml.append_child(table, element)

            # add history, input and output for the load view (designed for app loading)
            if my.view == 'load':
                element = my.xml.create_element("element")
                Xml.set_attribute(element, "name", "checkin")
                my.xml.append_child(table, element)
                for column in ['input', 'output']:
                    element = my.xml.create_element("element")
                    Xml.set_attribute(element, "name", column)
                    Xml.set_attribute(element, "edit", "false")
                    display_element = my.xml.create_element("display")
                    
                    Xml.set_attribute(display_element, "class", "tactic.ui.cgapp.LoaderElementWdg")
                    my.xml.append_child(element, display_element)

                    stype, key = SearchType.break_up_key(my.search_type)
                    op1 = my.xml.create_text_element("search_type", stype)
                    op2 = my.xml.create_text_element("mode", column)

                    
                    my.xml.append_child(display_element, op1)
                    my.xml.append_child(display_element, op2)

                    my.xml.append_child(table, element)
                
        value = my.xml.to_string()
        
        my.xml = Xml()
        my.xml.read_string(value)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:54,代码来源:sobject_default_config.py

示例6: get_sobjects_by_node

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import set_attribute [as 别名]
    def get_sobjects_by_node(my, node):
        # get the sobjects        
        search_type = my.xml.get_attribute(node, "search_type")
        expr = my.xml.get_attribute(node, "expression")
        code = my.xml.get_attribute(node, "code")


        if expr:
            sobjects = Search.eval(expr)

        elif search_type:
            search = Search(search_type)
            search.set_show_retired(True)
            if code:
                search.add_filter("code", code)


            # have some specific attributes for specific search types
            # can use wildcards like % and *
            if search_type == 'config/widget_config':
                view = Xml.get_attribute(node, "view")
                if view:
                    ignore_columns = 'id,code'
                    Xml.set_attribute(node, "ignore_columns", ignore_columns)

                    if view.find("%") != -1 or view.find("*") != -1:
                        view = view.replace("*", "%")
                        view = view.replace("/", ".")
                        search.add_filter("view", view, op="like")
                    else:
                        search.add_filter("view", view)

            elif search_type == 'config/url':
                url = Xml.get_attribute(node, "url")
                if url:
                    ignore_columns = 'id,code'
                    Xml.set_attribute(node, "ignore_columns", ignore_columns)
                    if url.find("%") != -1:
                        search.add_filter("url", url, op="like")
                    else:
                        search.add_filter("url", url)
 


            search.add_order_by("id")
            sobjects = search.get_sobjects()
        else:
            sobjects = []


        return sobjects
开发者ID:blezek,项目名称:TACTIC,代码行数:53,代码来源:plugin.py

示例7: get_default_task_xml

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import set_attribute [as 别名]
    def get_default_task_xml():
        global TASK_PIPELINE

        from pyasm.web import Palette
        palette = Palette.get()
        xml = Xml()
        xml.read_string(TASK_PIPELINE)
        nodes = Xml.get_nodes(xml, "pipeline/process")
        for node in nodes:
            process = Xml.get_attribute(node, "name")
            color = Task.get_default_color(process)
            Xml.set_attribute(node, "color", color)

        return xml.to_string()
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:16,代码来源:task.py

示例8: dump

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import set_attribute [as 别名]
    def dump(my, plugin_code, project_code, search_types):

        xml = Xml()
        my.xml = xml

        xml.create_doc("manifest")
        manifest_node = xml.get_root_node()
        xml.set_attribute(manifest_node, "code", plugin_code)

        # DUMP the data
        for search_type in search_types:

            data_node = xml.create_element("search_type")
            xml.append_child(manifest_node, data_node)
            xml.set_attribute(data_node, "code", search_type)

            # This exports the data
            """
            data_node = xml.create_element("sobject")
            xml.append_child(manifest_node, data_node)
            xml.set_attribute(data_node, "search_type", search_type)

            # find the currval 
            st_obj = SearchType.get(search_type)
            # have to call nextval() to initiate this sequence in the session in psql since Postgres 8.1
            seq_id = st_obj.sequence_nextval()
            
            seq_id = st_obj.sequence_currval()

            seq_id -= 1
            if seq_id > 0:
                st_obj.sequence_setval(seq_id)
            xml.set_attribute(data_node, "seq_max", seq_id)
            """
            


        print xml.to_string()

        # create a virtual plugin
        plugin = SearchType.create("sthpw/plugin")
        plugin.set_value("version", "1.0.0")
        plugin.set_value("code", "%s_project" % project_code)

        base_dir = "./templates"
        creator = PluginCreator( base_dir=base_dir, plugin=plugin, manifest=xml.to_string() )
        creator.execute()
开发者ID:0-T-0,项目名称:TACTIC,代码行数:49,代码来源:schema_dump_cmd.py

示例9: _get_edit_config

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import set_attribute [as 别名]
 def _get_edit_config(self, view, process_names):
     xml = Xml()
     xml.create_doc("config")
     root = xml.get_root_node()
     view_node = xml.create_element(view)
     #root.appendChild(view_node)
     xml.append_child(root, view_node)
     for idx, process_name in enumerate(process_names):
         element  = xml.create_element('element')
         Xml.set_attribute(element, 'name', process_name)
         #view_node.appendChild(element)
         xml.append_child(view_node, element)
         display =   xml.create_element('display')
         Xml.set_attribute(display, 'class', "pyasm.widget.TextAreaWdg")
         #element.appendChild(display)
         xml.append_child(element, display)
     
     config_xml = xml.to_string()
     widget_config = WidgetConfig.get(view=view, xml = config_xml)
     widget_config_view = WidgetConfigView('sthpw/note', view, [widget_config])
     return widget_config_view
开发者ID:mincau,项目名称:TACTIC,代码行数:23,代码来源:note_wdg.py

示例10: handle_config2

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import set_attribute [as 别名]
    def handle_config2(my):
        """for db column search config stuff, not used yet"""
        web = WebContainer.get_web()

        search_type = "SearchTypeSchema"
        view = "definition"

        config_search_type = "config/widget_config"

        search = Search(config_search_type)
        search.add_filter("search_type", search_type)
        search.add_filter("view", view)
        config = search.get_sobject()
        if not config:
            config = SearchType.create(config_search_type)
            config.set_value("search_type", search_type)
            config.set_value("view", view)
            xml = config.get_xml_value("config", "config")
            root = xml.get_root_node()
            # reinitialize
            config._init()

            # build a new config
            view_node = xml.create_element(view)
            root.appendChild(view_node)

        config_mode = web.get_form_value("config_mode")
        if config_mode == "advanced":
            config_string = web.get_form_value("config_xml")
        else:
            config_data_type = web.get_form_value("config_data_type")
            if config_data_type == "Other...":
                config_data_type = web.get_form_value("config_data_type_custom")
            config_nullable = web.get_form_value("config_nullable")

            # TAKEN FROM API: should be centralized or something
            from tactic.ui.panel import SideBarBookmarkMenuWdg

            config_view = SideBarBookmarkMenuWdg.get_config(search_type, view)
            node = config_view.get_element_node(my.element_name)
            if node:
                config_xml = config_view.get_xml()

                node = config_view.get_element_node(my.element_name)
                Xml.set_attribute(node, "data_type", config_data_type)
                Xml.set_attribute(node, "nullable", config_nullable)
                Xml.set_attribute(node, "new", "True")

                config_string = config_xml.to_string(node)
            else:
                config_string = """
                <element name="%s" data_type="%s" nullable="%s" new="True"/>
                """ % (
                    my.element_name,
                    config_data_type,
                    config_nullable,
                )

        config.append_xml_element(my.element_name, config_string)
        config.commit_config()
开发者ID:pombredanne,项目名称:TACTIC,代码行数:62,代码来源:search_type_manager_wdg.py

示例11: _get_main_config

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import set_attribute [as 别名]
    def _get_main_config(self, view, process_names):
        '''get the main config for this table layout'''
        xml = Xml()
        xml.create_doc("config")
        root = xml.get_root_node()
        view_node = xml.create_element(view)
        #root.appendChild(view_node)
        xml.append_child(root, view_node)
        
        for idx, process_name in enumerate(process_names):
            element  = xml.create_element('element')
            Xml.set_attribute(element, 'name', process_name)
            #view_node.appendChild(element)
            xml.append_child(view_node, element)
            display =   xml.create_element('display')
            if self.element_class:
                Xml.set_attribute(display, 'class',self.element_class)
            else:
                Xml.set_attribute(display, 'class', "tactic.ui.app.NoteTableElementWdg")
            #element.appendChild(display)
            xml.append_child(element, display)

            op_element = xml.create_data_element('parent_key', self.search_key)
            xml.append_child(display, op_element)
            

        config_xml = xml.to_string()
        widget_config = WidgetConfig.get(view=view, xml = config_xml)
        widget_config_view = WidgetConfigView('sthpw/note', view, [widget_config])

        return widget_config_view
开发者ID:mincau,项目名称:TACTIC,代码行数:33,代码来源:note_wdg.py

示例12: serialize

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import set_attribute [as 别名]
    def serialize(my):
        '''provide the ability for a widget to serialize itself'''

        xml = Xml()
        xml.create_doc("config")

        # create the top element
        element = xml.create_element("element")
        xml.set_attribute(element, "name", my.name)

        # create the display handler
        display = xml.create_element("display")
        xml.set_attribute(display, "class", Common.get_full_class_name(my) )
        element.appendChild(display)

        # create the options
        for name, value in my.kwargs.items():
            if value:
                option = xml.create_text_element(name, value)
            else:  # avoid the \n in the textContent of the textNode 
                option = xml.create_element(name) 
            display.appendChild(option)

        return xml.to_string(element)
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:26,代码来源:base_refresh_wdg.py

示例13: execute

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import set_attribute [as 别名]
    def execute(self):
        sobject = self.sobject

        name = self.get_name()

        web = WebContainer.get_web()

        naming = web.get_form_value(name)

        if not naming:
            return

        xml = Xml(string=naming)
        sample_name = xml.get_value("naming/@sample")

        parts = re.split( '[\\/._]', sample_name)


        # make some adjustments based on selections
        nodes = xml.get_nodes("naming/part")
        for idx, node in enumerate(nodes):

            type_value = web.get_form_value("type_%s" % idx)
            part = parts[idx]

            if not type_value:
                continue

            if type_value == "placeholder":
                Xml.set_attribute(nodes[idx], "type", "placeholder")
                Xml.set_attribute(nodes[idx], "value", part)
            else:
                a, b = type_value.split("/")
                Xml.set_attribute(nodes[idx], "type", a)
                Xml.set_attribute(nodes[idx], "name", b)

        naming = xml.to_string() 


        sobject.set_value(name, naming)
开发者ID:mincau,项目名称:TACTIC,代码行数:42,代码来源:naming_wdg.py

示例14: set_attribute

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import set_attribute [as 别名]
 def set_attribute(my, name, value):
     return Xml.set_attribute(my.node, name, value)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:4,代码来源:pipeline.py

示例15: handle_basic_mode

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import set_attribute [as 别名]
    def handle_basic_mode(my):

        doc = my.xml.create_doc("config")
        root = my.xml.get_root_node()
        
        db_columns = my.get_columns()

        if "code" in db_columns:
            columns = ["preview", "code"]
        elif "name" in db_columns:
            columns = ["preview", "name"]
        elif "id" in db_columns:
            columns = ["preview", "id"]


        table = my.xml.create_element("table")
        Xml.append_child(root, table)
        for column in ["preview", "code"]:
            element = my.xml.create_element("element")
            Xml.set_attribute(element, "name", column)
            Xml.append_child(table, element)

        # create the edit
        edit = my.xml.create_element("edit")
        Xml.append_child(root, edit)

        for column in ["preview", "code"]:
            element = my.xml.create_element("element")
            Xml.set_attribute(element, "name", column)
            Xml.append_child(edit, element)


        # create the manual publish view
        publish = my.xml.create_element("publish")
        Xml.append_child(root, publish)
        element = my.xml.create_element("element")
        Xml.set_attribute(element, "name", "image")
        Xml.append_child(publish, element)
        dis_element = my.xml.create_element("display")
        Xml.set_attribute(dis_element, "class", "ThumbInputWdg")
        act_element = my.xml.create_element("action")
        Xml.set_attribute(act_element, "class", "NullAction")
        Xml.append_child(element, dis_element)
        Xml.append_child(element, act_element)

        element = my.xml.create_element("element")
        Xml.set_attribute(element, "name", "publish_files")
        Xml.append_child(publish, element)
        dis_element = my.xml.create_element("display")
        Xml.set_attribute(dis_element, "class", "UploadWdg")
        # add options
        option = my.xml.create_text_element('names','publish_icon|publish_main')
        Xml.append_child(dis_element, option)
        option = my.xml.create_text_element('required','false|true')
        Xml.append_child(dis_element, option)

        act_element = my.xml.create_element("action")
        Xml.set_attribute(act_element, "class", "MultiUploadAction")
        # add options
        option = my.xml.create_text_element('names','publish_icon|publish_main')
        Xml.append_child(act_element, option)
        option = my.xml.create_text_element('types','icon_main|main')
        Xml.append_child(act_element, option)
        Xml.append_child(element, dis_element)
        Xml.append_child(element, act_element)

        value = my.xml.to_string()
        my.xml = Xml()
        my.xml.read_string(value)
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:71,代码来源:sobject_default_config.py


注:本文中的pyasm.common.Xml.set_attribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。