本文整理汇总了Python中pyasm.common.Xml类的典型用法代码示例。如果您正苦于以下问题:Python Xml类的具体用法?Python Xml怎么用?Python Xml使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Xml类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_input_snapshots
def get_input_snapshots(my, sobject, process_name, input_name, version='latest'):
'''gets the snapshots of the input'''
assert version in ['latest', 'current']
process_node = my.xml.get_node( "pipeline/process[@name='%s']/input[@name='%s']" % (process_name, input_name))
search_type = Xml.get_attribute(process_node, "search_type")
context = Xml.get_attribute(process_node, "context")
filter = Xml.get_attribute(process_node, "filter")
# get the sobjects
sobjects = sobject.get_all_children(search_type)
# get the snapshots
search = Search("sthpw/snapshot")
search.add_filter('context', context)
#if version == 'latest':
# search.add_filter("is_latest", 1)
#elif version == 'current':
# search.add_filter("is_current", 1)
# build filters for search_type, search_id combinations
filters = []
for sobject in sobjects:
filter = "(\"search_type\" = '%s' and \"search_id\" = %s)" % (sobject.get_search_type(), sobject.get_id() )
filters.append(filter)
search.add_where( "( %s )" % " or ".join(filters) )
snapshots = search.get_sobjects()
return snapshots
开发者ID:0-T-0,项目名称:TACTIC,代码行数:33,代码来源:pipeline.py
示例2: execute
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,代码行数:60,代码来源:search_wdg.py
示例3: get_related_search_types
def get_related_search_types(self, search_type, direction=None):
related_types = []
if not direction or direction == "parent":
xpath = "schema/connect[@from='%s']" %(search_type)
connects = self.xml.get_nodes(xpath)
for connect in connects:
related_type = Xml.get_attribute(connect,"to")
related_types.append(related_type)
if not direction or direction == "children":
xpath = "schema/connect[@to='%s']" %(search_type)
connects = self.xml.get_nodes(xpath)
for connect in connects:
related_type = Xml.get_attribute(connect,"from")
related_types.append(related_type)
if self.parent_schema:
search_types = self.parent_schema.get_related_search_types(search_type, direction=direction)
related_types.extend(search_types)
if self.sthpw_schema:
search_types = self.sthpw_schema.get_related_search_types(search_type, direction=direction)
related_types.extend(search_types)
return related_types
开发者ID:mincau,项目名称:TACTIC,代码行数:27,代码来源:schema.py
示例4: get_child_types
def get_child_types(self, search_type, relationship="hierarchy", hierarchy=True):
if search_type.find("?") != -1:
search_type, tmp = search_type.split("?", 1)
child_types = []
# first get the child types defined in the admin schema
if hierarchy and self.sthpw_schema:
sthpw_child_types = self.sthpw_schema.get_child_types(search_type, relationship)
child_types.extend(sthpw_child_types)
# get the child types in the project type schema
if hierarchy and self.parent_schema:
parent_child_types = self.parent_schema.get_child_types(search_type, relationship)
child_types.extend(parent_child_types)
# add new style
connects = self.xml.get_nodes("schema/connect[@to='%s'] | schema/connect[@to='*']" % search_type)
for connect in connects:
relationship = Xml.get_attribute(connect, "relationship")
# skip old style
if not relationship:
continue
child_type = Xml.get_attribute(connect, "from")
# skip identical type
if child_type == search_type:
continue
child_types.append(child_type)
return child_types
开发者ID:mincau,项目名称:TACTIC,代码行数:32,代码来源:schema.py
示例5: delete_files
def delete_files(my, nodes):
# clean out all of the files
for node in nodes:
name = my.xml.get_node_name(node)
if name == "include":
path = my.xml.get_attribute(node, "path")
if not path:
print("WARNING: No path found for search type in manifest")
continue
path = "%s/%s" % (my.plugin_dir, path)
if path.endswith(".py"):
from tactic.command import PythonCmd
cmd = PythonCmd(file_path=path)
manifest = cmd.execute()
if manifest:
xml = Xml()
xml.read_string(manifest)
include_nodes = xml.get_nodes("manifest/*")
my.delete_files(include_nodes)
elif name == "python":
# don't delete python node file
pass
else:
path = my.get_path_from_node(node)
if path and os.path.exists(path):
print "Deleting: ", path
os.unlink(path)
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:32,代码来源:plugin.py
示例6: _test_accept
def _test_accept(my):
# try json
url = "http://localhost/tactic/unittest/rest"
headers = {
"Accept": "application/json"
}
ret_val = my.send_request(url, headers)
my.assertEquals( [3,2,1], ret_val)
# try xml
url = "http://localhost/tactic/unittest/rest"
headers = {
"Accept": "application/xml"
}
ret_val = my.send_request(url, headers)
xml = Xml(ret_val)
values = xml.get_values("arr/int")
my.assertEquals( ['1','2','3'], values)
# try json
url = "http://localhost/tactic/unittest/rest/CODE0123"
headers = {
"Accept": "application/json"
}
ret_val = my.send_request(url, headers)
my.assertEquals( "OK", ret_val)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:29,代码来源:rest_test.py
示例7: handle_include
def handle_include(my, node):
path = my.xml.get_attribute(node, "path")
if not path:
raise TacticException("No path found for include in manifest")
path = "%s/%s" % (my.plugin_dir, path)
if path.endswith(".py"):
from tactic.command import PythonCmd
cmd = PythonCmd(file_path=path)
manifest = cmd.execute()
if not manifest:
print "No manifest discovered in [%s]" %path
return
xml = Xml()
xml.read_string(manifest)
nodes = xml.get_nodes("manifest/*")
sobjects = []
for i, node in enumerate(nodes):
name = my.xml.get_node_name(node)
if name == 'sobject':
dumped_sobjects = my.handle_sobject(node)
if not dumped_sobjects:
dumped_sobjects = []
sobjects.extend(dumped_sobjects)
elif name == 'search_type':
my.handle_search_type(node)
elif name == 'include':
my.handle_include(node)
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:32,代码来源:plugin.py
示例8: add_attr_access
def add_attr_access(self, search_type, attr, level):
# find the group
group_xpath = "rules/group[@key='%s']" % (search_type)
group = self.xml.get_node(group_xpath)
if group == None:
# add the group (default to view)
group_level = "view"
group = self.add_sobject_access(search_type,group_level)
# get the attr rule
rule_xpath = "rules/group[@key='%s']/rule[@key='%s']" % (search_type,attr)
rule = self.xml.get_node(rule_xpath )
if rule != None:
# if nothing has changed, continue
access = Xml.get_attribute(rule,"access")
if level == access:
raise CommandExitException()
else:
rule = self.xml.create_element("rule")
rule.setAttributeNS(None,"key",attr)
#group.appendChild(rule)
Xml.append_child(group, rule)
#self.root.appendChild(group)
Xml.append_child(self.root, group)
# set the access level
rule.setAttributeNS(None,"type","attr")
rule.setAttributeNS(None,"access",level)
开发者ID:mincau,项目名称:TACTIC,代码行数:32,代码来源:add_user_to_group_cmd.py
示例9: execute
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,代码行数:60,代码来源:fix_duplicate_file_code.py
示例10: get_config
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,代码行数:58,代码来源:simple_search_wdg.py
示例11: get_plugin_data
def get_plugin_data(my, reldir):
manifest_path = "%s/%s/manifest.xml" % (my.base_dir, reldir)
xml = Xml()
xml.read_file(manifest_path)
node = xml.get_node("manifest/data")
data = xml.get_node_values_of_children(node)
return data
开发者ID:0-T-0,项目名称:TACTIC,代码行数:9,代码来源:plugin_util.py
示例12: handle_config
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,代码行数:56,代码来源:view_manager_wdg.py
示例13: _read_ref_file
def _read_ref_file(my):
'''read the reference file containing extra node information'''
dir = my.get_upload_dir()
xml = Xml()
key = my.sobject.get_code()
# make this filename good for the file system
filename = File.get_filesystem_name(key)
xml.read_file( "%s/%s-ref.xml" % (dir,filename) )
return xml
开发者ID:0-T-0,项目名称:TACTIC,代码行数:10,代码来源:flash_publish_cmd.py
示例14: get_config
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("<", "<")
config_xml = config_xml.replace(">", ">")
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,代码行数:55,代码来源:simple_search_wdg.py
示例15: _test_guest_allow
def _test_guest_allow(self):
'''test Config tag allow_guest in security tag.
Note: Since it is hard to emulate AppServer class,
this is based on logic which handles in _get_display
of BaseAppServer.
1. If allow_guest is false, then it is necessary that
Sudo is instantiated.
2. If allow_guest is true, then it is necessary that
guest login rules are added and login_as_guest is
executed.
'''
security = Security()
Environment.set_security(security)
#1. allow_guest is false
fail = False
try:
sudo = Sudo()
except Exception as e:
fail = True
self.assertEquals( False, fail )
sudo.exit()
key = [{'code': "*"}]
project_access = security.check_access("project", key, "allow")
self.assertEquals(project_access, False)
#2. allow_guest is true
Site.set_site("default")
try:
security.login_as_guest()
ticket_key = security.get_ticket_key()
access_manager = security.get_access_manager()
xml = Xml()
xml.read_string('''
<rules>
<rule column="login" value="{$LOGIN}" search_type="sthpw/login" access="deny" op="!=" group="search_filter"/>
<rule group="project" code="default" access="allow"/>
</rules>
''')
access_manager.add_xml_rules(xml)
finally:
Site.pop_site()
default_key = [{'code': "default"}]
project_access = security.check_access("project", default_key, "allow")
self.assertEquals(project_access, True)
unittest_key = [{'code', "sample3d"}]
project_access = security.check_access("project", unittest_key, "allow")
self.assertEquals(project_access, False)
开发者ID:mincau,项目名称:TACTIC,代码行数:55,代码来源:security_test.py
示例16: get_parent_type
def get_parent_type(my, search_type, relationship=None):
# NOTE: relationship arg is deprecated!!
if search_type.find("?") != -1:
search_type, tmp = search_type.split("?", 1)
# make a provision for admin search_types passed in
if my.get_code() != "admin" and search_type.startswith("sthpw/"):
parent_type = Schema.get_admin_schema().get_parent_type(search_type, relationship)
if parent_type:
return parent_type
parent_type = ""
# look at new style connections first
connects = my.xml.get_nodes("schema/connect[@from='%s']" % search_type )
for connect in connects:
relationship_new = Xml.get_attribute(connect, "relationship")
if relationship_new:
type = Xml.get_attribute(connect, "type")
if type == 'hierarchy':
parent_type = Xml.get_attribute(connect, "to")
break
# NOTE: there could be multiple parents here. Hierarchy type
# should be the one to resolve this.
# if there is no "hierarchy" type, use the first one
if not parent_type:
for connect in connects:
from_type = Xml.get_attribute(connect, "from")
if from_type == search_type:
parent_type = Xml.get_attribute(connect, "to")
break
"""
# DEPRECATED: resort to old style
if not parent_type:
connects = my.xml.get_nodes("schema/connect[@to='%s']" % search_type )
# FIXME: you need to assign parent_type here
for connect in connects:
type = Xml.get_attribute(connect, "type")
if type != relationship:
continue
parent_type = Xml.get_attribute(connect, "from")
# FIXME: should we call break?
"""
if not parent_type and my.parent_schema:
parent_type = my.parent_schema.get_parent_type(search_type, relationship)
return parent_type
开发者ID:davidsouthpaw,项目名称:TACTIC,代码行数:55,代码来源:schema.py
示例17: get_task_pipeline
def get_task_pipeline(my, default=True):
''' assuming the child pipeline is task related '''
task_pipeline_code = Xml.get_attribute( my.node, "task_pipeline" )
node_type = Xml.get_attribute(my.node, "type")
if node_type == "approval":
return "approval"
if not task_pipeline_code and default:
return "task"
else:
return task_pipeline_code
开发者ID:nuxping,项目名称:TACTIC,代码行数:11,代码来源:pipeline.py
示例18: execute
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,代码行数:12,代码来源:copy_config_cmd.py
示例19: get_action_nodes
def get_action_nodes(my, scope="dependent"):
action_nodes = []
nodes = Xml.get_children(my.node)
for node in nodes:
node_name = Xml.get_node_name(node)
if node_name == "action":
node_scope = Xml.get_attribute(node, "scope")
if scope and node_scope != scope:
continue
action_nodes.append(node)
return action_nodes
开发者ID:0-T-0,项目名称:TACTIC,代码行数:12,代码来源:pipeline.py
示例20: handle_columns_mode
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,代码行数:52,代码来源:sobject_default_config.py
注:本文中的pyasm.common.Xml类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论