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


Python Xml.to_string方法代码示例

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


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

示例1: _get_main_config

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import to_string [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

示例2: execute

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

        # create the filters
        my.filters = []
        """
        for element_name in my.config.get_element_names():
            
            filter = my.config.get_display_widget(element_name)
            my.filters.append(filter)

        # make sure there is at least one filter defined
        assert my.filters

        """
        config = "<config>\n"
        config += "<filter>\n"

        # get all of the serialized versions of the filters
        """
        for filter in my.filters:
            config += filter.serialize() + "\n"
        """
        filter_data = FilterData.get()
        json = filter_data.serialize()
        value_type = "json"
        config += "<values type='%s'>%s</values>\n" % (value_type, json)
        config += "</filter>\n"
        config += "</config>\n"

        # format the xml
        xml = Xml()
        xml.read_string(config)

        if not my.view:
            saved_view = "saved_search:%s" % my.search_type
        else:
            saved_view = my.view
        #    if my.view.startswith("saved_search:"):
        #        saved_view = my.view
        #    else:
        #        saved_view = "saved_search:%s" % my.view

        # use widget config instead
        search = Search("config/widget_config")
        search.add_filter("view", saved_view)
        search.add_filter("search_type", my.search_type)
        if my.personal:
            search.add_user_filter()
        config = search.get_sobject()

        if not config:
            config = SearchType.create("config/widget_config")
            config.set_value("view", saved_view)
            config.set_value("search_type", my.search_type)
            if my.personal:
                config.set_user()

        config.set_value("config", xml.to_string())
        config.commit()
开发者ID:raidios,项目名称:TACTIC,代码行数:62,代码来源:search_wdg.py

示例3: execute

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import to_string [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

示例4: dump

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import to_string [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

示例5: get_config

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import to_string [as 别名]
    def get_config(my):
        # TEST
        config_xml = '''
        <config>
        <custom_filter>
          <element name='asset_library'>
            <display class='SelectWdg'>
                <query>prod/asset_library|code|code</query>
                <empty>true</empty>
            </display>
          </element>
          <element name='pipeline_code'>
            <display class='SelectWdg'>
                <query>sthpw/pipeline|code|code</query>
                <empty>true</empty>
            </display>
          </element>
        </custom_filter>
        </config>
        '''

        my.view = my.kwargs.get("search_view")
        if not my.view:
            my.view = 'custom_filter'
        #view = "custom_filter"
        project_code = Project.extract_project_code(my.search_type)
        search = Search("config/widget_config", project_code=project_code )
        search.add_filter("view", my.view)
        
       
        search.add_filter("search_type", my.base_search_type)
        config_sobj = search.get_sobject()
        if config_sobj:
            config_xml = config_sobj.get_value("config")
        
        else:
            config_xml = '''
            <config>
            <custom_filter>
            </custom_filter>
            </config>
            '''
            # use the one defined in the default config file
            file_configs = WidgetConfigView.get_configs_from_file(my.base_search_type, my.view)
            if file_configs:
                config = file_configs[0]
                xml_node = config.get_view_node()
                if xml_node is not None:
                    xml = Xml(config.get_xml().to_string())
                    config_xml = '<config>%s</config>' %xml.to_string(node=xml_node)

            


        from pyasm.widget import WidgetConfig
        config = WidgetConfig.get(view=my.view, xml=config_xml)

        return config
开发者ID:funic,项目名称:TACTIC,代码行数:60,代码来源:simple_search_wdg.py

示例6: get_config

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


        self.view = self.kwargs.get("search_view")
        config = self.kwargs.get("search_config")

        if not self.view:
            self.view = 'custom_filter'
        #view = "custom_filter"

        project_code = Project.extract_project_code(self.search_type)

        search = Search("config/widget_config", project_code=project_code )
        search.add_filter("view", self.view)
        search.add_filter("search_type", self.base_search_type)
        config_sobjs = search.get_sobjects()

        from pyasm.search import WidgetDbConfig
        config_sobj = WidgetDbConfig.merge_configs(config_sobjs)

        if config_sobj:
            #config_xml = config_sobj.get("config")
            config_xml = config_sobj.get_xml().to_string()
            config_xml = config_xml.replace("&lt;", "<")
            config_xml = config_xml.replace("&gt;", ">")
            config_xml = Common.run_mako(config_xml)

        elif config:
            config_xml = '''
            <config>
            <custom_filter>%s
            </custom_filter>
            </config>
            ''' % config
        else:
            config_xml = '''
            <config>
            <custom_filter>
            </custom_filter>
            </config>
            '''
            # use the one defined in the default config file
            file_configs = WidgetConfigView.get_configs_from_file(self.base_search_type, self.view)
            if file_configs:
                config = file_configs[0]
                xml_node = config.get_view_node()
                if xml_node is not None:
                    xml = Xml(config.get_xml().to_string())
                    config_xml = '<config>%s</config>' %xml.to_string(node=xml_node)

            
        from pyasm.widget import WidgetConfig
        config = WidgetConfig.get(view=self.view, xml=config_xml)

        return config
开发者ID:mincau,项目名称:TACTIC,代码行数:57,代码来源:simple_search_wdg.py

示例7: execute

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

        # copy all of the widget configs from the prod definition and put
        # them into the database
        xml = Xml(string=test_xml)

        search_type = "SideBarWdg"
        view = "cow"
        config = WidgetDbConfig.create(search_type, view, data=xml.to_string())

        '''
开发者ID:mincau,项目名称:TACTIC,代码行数:14,代码来源:copy_config_cmd.py

示例8: get_default_task_xml

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import to_string [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

示例9: execute

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

        # create the filters
        self.filters = []

        config = "<config>\n"
        config += "<filter>\n"

        # get all of the serialized versions of the filters
        filter_data = FilterData.get()
        json = filter_data.serialize()
        value_type = "json"
        config += "<values type='%s'>%s</values>\n" % (value_type, json)
        config += "</filter>\n"
        config += "</config>\n"
        

        # format the xml
        xml = Xml()
        xml.read_string(config)


        if not self.view:
            saved_view = "saved_search:%s" % self.search_type
        else:
            saved_view = self.view
        #    if self.view.startswith("saved_search:"):
        #        saved_view = self.view
        #    else:
        #        saved_view = "saved_search:%s" % self.view

        # use widget config instead
        search = Search('config/widget_config')
        search.add_filter("view", saved_view)
        search.add_filter("search_type", self.search_type)
        if self.personal:
            search.add_user_filter()
        config = search.get_sobject()

        if not config:
            config = SearchType.create('config/widget_config')
            config.set_value("view", saved_view)
            config.set_value("search_type", self.search_type)
            if self.personal:
                config.set_user()

        config.set_value("category", "search_filter")
        config.set_value("config", xml.to_string())
        config.commit()
开发者ID:mincau,项目名称:TACTIC,代码行数:52,代码来源:search_wdg.py

示例10: get_by_ticket

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import to_string [as 别名]
    def get_by_ticket(ticket):
        search = Search(TransactionState)
        search.add_filter("ticket", ticket)
        state = search.get_sobject()

        # create the state data for this ticket
        if not state:
            state = SObjectFactory.create(TransactionState.SEARCH_TYPE)
            state.set_value("ticket", ticket)
            data = Xml()
            data.create_doc("state")
            state.set_value("data", data.to_string() )
            state.commit()

        return state
开发者ID:0-T-0,项目名称:TACTIC,代码行数:17,代码来源:transaction_state.py

示例11: import_schema

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import to_string [as 别名]
def import_schema(plugin_code):
    from pyasm.search import Transaction
    transaction = Transaction.get(create=True)

    install_dir = Environment.get_install_dir()
    base_dir = Environment.get_plugin_dir()
    template_dir = "%s/%s" % (base_dir, plugin_code)
    manifest_path = "%s/manifest.xml" % (template_dir)
    print "Reading manifest: ", manifest_path

    xml = Xml()
    xml.read_file(manifest_path)

    # create a new project
    installer = PluginInstaller(base_dir=base_dir, manifest=xml.to_string() )
    installer.execute()
开发者ID:0-T-0,项目名称:TACTIC,代码行数:18,代码来源:bootstrap_load.py

示例12: _get_edit_config

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import to_string [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

示例13: execute

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import to_string [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: serialize

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import to_string [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

示例15: execute

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

        print "kwargs: ", self.kwargs

        options = {}
        class_name = "tactic.ui.panel.CustomLayoutWdg"
        widget_key = ""
        for key, value in self.kwargs.items():
            if value == '':
                continue

            if key.startswith("xxx_option"):
                parts = key.split("|")
                option_key = parts[1]

                if option_key == "display_class":
                    class_name = value
                elif option_key == "widget_key":
                    widget_key = value
                else:
                    options[option_key] = value

            elif key.startswith("option|"):
                parts = key.split("|")
                option_key = parts[1]
                options[option_key] = value



        print "options: ", options

        name = self.kwargs.get("name")
        description = self.kwargs.get("description") or " "

        if not name:
            raise Exception("No name provided")


        name = Common.clean_filesystem_name(name)

        login = Environment.get_user_name()
        view = "pages.%s.%s" % (login, name)


        # find if this user page already exists
        search = Search("config/widget_config")
        search.add_filter("category", "CustomLayoutWg")
        search.add_filter("view", view)
        config = search.get_sobject()

        if config:
            raise Exception("Page with name [%s] already exists" % name)


        option_xml = []
        for key, value in options.items():
            option_xml.append("<%s>%s</%s>" % (key, value, key))
        option_str = "\n".join(option_xml)


        if widget_key:
            display_line = '''<display widget="%s">''' % widget_key
        else:
            display_line = '''<display class="%s">''' % class_name



        # all pages are custom layouts
        config_xml = '''<config>
  <%s>
    <html>
    <div style="margin: 20px">
      <div style="font-size: 25px">%s</div>
      <div>%s</div>
      <hr/>
      <element>
        %s
        %s
        </display>
      </element>
    </div>
    </html>
  </%s>
</config>
        ''' % (view, name, description, display_line, option_str, view)

        print "config_xml: ", config_xml

        xml = Xml()
        xml.read_string(config_xml)
        config_xml = xml.to_string()

        config = SearchType.create("config/widget_config")
        config.set_value("category", "CustomLayoutWdg")
        config.set_value("view", view)
        config.set_value("config", config_xml)

        config.commit()
开发者ID:mincau,项目名称:TACTIC,代码行数:100,代码来源:panel_wdg.py


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