本文整理汇总了Python中pyasm.search.Search.get_sobject_ids方法的典型用法代码示例。如果您正苦于以下问题:Python Search.get_sobject_ids方法的具体用法?Python Search.get_sobject_ids怎么用?Python Search.get_sobject_ids使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.search.Search
的用法示例。
在下文中一共展示了Search.get_sobject_ids方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_insert
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_sobject_ids [as 别名]
def on_insert(my):
'''Function that should be run on insert/update. It's already automatically called during insert.
On update, the caller needs to call this explicitly. It checks the search type
this pipeline is associated with and if there is no pipeline code
column, then update it. It updates the process table also.'''
search_type = my.get_value('search_type')
my.update_process_table(search_type=search_type)
# don't do anything for task sType
if search_type =='sthpw/task':
return
if not search_type:
return
if ProdSetting.get_value_by_key('autofill_pipeline_code') != 'false':
try:
columns = SearchType.get_columns(search_type)
if not 'pipeline_code' in columns:
# add the pipeline code column
from pyasm.command import ColumnAddCmd
cmd = ColumnAddCmd(search_type, "pipeline_code", "varchar")
cmd.execute()
except SqlException, e:
print "Error creating column [pipeline_code] for %" %search_type
pass
# go through all of the sobjects and set all the empty ones
# to the new pipeline
search = Search(search_type)
search.add_op("begin")
search.add_filter("pipeline_code", "NULL", op='is', quoted=False)
search.add_filter("pipeline_code", "")
search.add_op("or")
sobject_ids = search.get_sobject_ids()
if sobject_ids:
# this is much faster and memory efficient
db_resource = SearchType.get_db_resource_by_search_type(search_type)
sql = DbContainer.get(db_resource)
tbl = search.get_table()
sobject_ids = [str(x) for x in sobject_ids]
pipeline_code = my.get_value("code")
sql.do_update('''UPDATE "%s" SET "pipeline_code" = '%s' WHERE id in (%s) ''' %(tbl, pipeline_code, ','.join(sobject_ids)))
"""