本文整理汇总了Python中pyasm.search.SearchType.sequence_currval方法的典型用法代码示例。如果您正苦于以下问题:Python SearchType.sequence_currval方法的具体用法?Python SearchType.sequence_currval怎么用?Python SearchType.sequence_currval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.search.SearchType
的用法示例。
在下文中一共展示了SearchType.sequence_currval方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: import_manifest
# 需要导入模块: from pyasm.search import SearchType [as 别名]
# 或者: from pyasm.search.SearchType import sequence_currval [as 别名]
#.........这里部分代码省略.........
paths_read.append(path)
if not jobs:
continue
search_type_obj = jobs[0]
if len(jobs) == 1:
# only the search type was defined
table = None
else:
table = jobs[1]
try:
# check to see if the search type already exists
search_type_chk = SearchType.get(search_type)
if search_type_chk:
if my.verbose:
print 'WARNING: Search Type [%s] is already registered' % search_type_chk.get_value("search_type")
else:
search_type_obj.commit()
except SearchException, e:
if e.__str__().find('not registered') != -1:
search_type_obj.commit()
# check if table exists
has_table = False
if has_table:
if my.verbose:
print 'WARNING: Table [%s] already exists'
elif table:
#print table.get_statement()
if table:
database = table.get_database()
table_name = table.get_table()
TableUndo.log(search_type, database, table_name)
elif node_name == 'sobject':
path = my.xml.get_attribute(node, "path")
search_type = my.xml.get_attribute(node, "search_type")
seq_max = my.xml.get_attribute(node, "seq_max")
try:
if seq_max:
seq_max = int(seq_max)
except ValueError:
seq_max = 0
if not path:
if search_type:
path = "%s.spt" % search_type.replace("/","_")
if not path:
raise TacticException("No path specified")
path = "%s/%s" % (my.plugin_dir, path)
if path in paths_read:
continue
unique = my.xml.get_attribute(node, "unique")
if unique == 'true':
unique = True
else:
unique = False
if my.verbose:
print "Reading: ", path
# jobs doesn't matter for sobject node
jobs = my.import_data(path, unique=unique)
# reset it in case it needs to execute a PYTHON tag right after
Schema.get(reset_cache=True)
# compare sequence
st_obj = SearchType.get(search_type)
SearchType.sequence_nextval(search_type)
cur_seq_id = SearchType.sequence_currval(search_type)
sql = DbContainer.get("sthpw")
if seq_max > 0 and seq_max > cur_seq_id:
# TODO: SQL Server - Reseed the sequences instead of passing.
if sql.get_database_type() == 'SQLServer':
pass
else:
SearchType.sequence_setval(search_type, seq_max)
else:
cur_seq_id -= 1
# TODO: SQL Server - Reseed the sequences instead of passing.
if sql.get_database_type() == 'SQLServer':
pass
else:
# this is a db requirement
if cur_seq_id > 0:
SearchType.sequence_setval(search_type, cur_seq_id)
paths_read.append(path)
示例2: export_template
# 需要导入模块: from pyasm.search import SearchType [as 别名]
# 或者: from pyasm.search.SearchType import sequence_currval [as 别名]
def export_template(my):
xml = Xml()
my.xml = xml
xml.create_doc("manifest")
manifest_node = xml.get_root_node()
# Old implementation. Code is now on the data node
xml.set_attribute(manifest_node, "code", my.template_project_code)
# dump the notification entries
data_node = xml.create_element("data")
xml.append_child(manifest_node, data_node)
code_node = xml.create_element("code")
xml.append_child(data_node, code_node)
xml.set_node_value(code_node, my.template_project_code)
version = my.kwargs.get("version") or ""
version_node = xml.create_element("version")
xml.append_child(data_node, version_node)
xml.set_node_value(version_node, version)
# dump the project entry
data_node = xml.create_element("sobject")
xml.append_child(manifest_node, data_node)
xml.set_attribute(data_node, "expression", "@SOBJECT(sthpw/project['code','%s'])" % my.project_code)
xml.set_attribute(data_node, "search_type", "sthpw/project")
xml.set_attribute(data_node, "unique", "true")
# dump the project_type entry
data_node = xml.create_element("sobject")
xml.append_child(manifest_node, data_node)
xml.set_attribute(data_node, "expression", "@SOBJECT(sthpw/project['code','%s'].sthpw/project_type)" % my.project_code)
xml.set_attribute(data_node, "search_type", "sthpw/project_type")
xml.set_attribute(data_node, "unique", "true")
# dump the schema entry
data_node = xml.create_element("sobject")
xml.append_child(manifest_node, data_node)
xml.set_attribute(data_node, "expression", "@SOBJECT(sthpw/schema['code','%s'])" % my.project_code)
xml.set_attribute(data_node, "search_type", "sthpw/schema")
xml.set_attribute(data_node, "unique", "true")
# find the project template search types
namespace = my.project_type
if not namespace or namespace == "default":
namespace = my.project_code
project_search_types = Search.eval("@GET(sthpw/search_object['namespace','%s'].search_type)" % namespace)
#project_types = Search.eval("@GET(sthpw/search_object['namespace','%s'].search_type)" % my.project_code)
# just dump the definition for data
for search_type in project_search_types:
data_node = xml.create_element("search_type")
xml.append_child(manifest_node, data_node)
xml.set_attribute(data_node, "code", search_type)
search_types = [
"config/custom_script",
"config/widget_config",
"config/naming",
"config/client_trigger",
"config/process",
"config/trigger",
"config/url",
#"config/ingest_rule",
#"config/ingest_session",
]
for search_type in search_types:
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 = SearchType.sequence_nextval(search_type)
seq_id = SearchType.sequence_currval(search_type)
seq_id -= 1
if seq_id > 0:
SearchType.sequence_setval(search_type, seq_id)
xml.set_attribute(data_node, "seq_max", seq_id)
#xml.set_attribute(data_node, "path", "data.spt")
#.........这里部分代码省略.........