本文整理汇总了Python中pyasm.search.Search.add_filters方法的典型用法代码示例。如果您正苦于以下问题:Python Search.add_filters方法的具体用法?Python Search.add_filters怎么用?Python Search.add_filters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.search.Search
的用法示例。
在下文中一共展示了Search.add_filters方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_security_wdg
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filters [as 别名]
def get_security_wdg(self):
div = DivWdg()
div.add_class("spt_security")
div.add("A server can sync either be scoped for a single project or all projects. Transactions that occur in the admin project never get synced.")
div.add("<br/>"*2)
div.add("Project: ")
search = Search("sthpw/project")
search.add_filters("code", ['admin','unittest'], op='not in')
search.add_order_by("title")
projects = search.get_sobjects()
select = SelectWdg("projects")
div.add(select)
labels = [x.get_value("title") for x in projects]
values = [x.get_value("code") for x in projects]
project_code = Project.get_project_code()
if project_code != 'admin':
select.set_value(project_code)
select.set_option("labels", labels)
select.set_option("values", values)
select.add_empty_option("-- All --")
div.add("<br/>"*2)
return div
示例2: preprocess
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filters [as 别名]
def preprocess(self):
sobjects = self.sobjects
if not sobjects:
return
# find all of the instances in a shot
sobject = sobjects[0]
foreign_key = sobject.get_foreign_key()
search_type = WebState.get().get_state("planner_search_type")
search = Search( search_type )
search.add_column(foreign_key)
if len(sobjects) == 1:
search.add_filter(foreign_key, sobject.get_code())
else:
search_codes = [x.get_code() for x in sobjects]
search.add_filters(foreign_key, search_codes)
search_type = sobject.get_search_type()
search.add_order_by(foreign_key)
children = search.get_sobjects()
# convert to a dictionary
for child in children:
code = child.get_value(foreign_key)
number = self.numbers.get(code)
if not number:
number = 0
number += 1
self.numbers[code] = number
示例3: execute
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filters [as 别名]
def execute(my):
my.collection_key = my.kwargs.get("collection_key")
my.search_keys = my.kwargs.get("search_keys")
collection = Search.get_by_search_key(my.collection_key)
collection_code = collection.get("code")
sobjects = Search.get_by_search_keys(my.search_keys)
search_codes = [x.get_code() for x in sobjects]
search_type = collection.get_base_search_type()
parts = search_type.split("/")
collection_type = "%s/%s_in_%s" % (parts[0], parts[1], parts[1])
search = Search(collection_type)
search.add_filter("parent_code", collection.get_code())
search.add_filters("search_code", search_codes)
items = search.get_sobjects()
for item in items:
item.delete()
my.add_description("Remove [%s] item(s) from Collection [%s]" % (len(my.search_keys), collection_code))
示例4: get_display
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filters [as 别名]
def get_display(self):
#project = Project.get()
schema = Schema.get()
# no hierarchy to prevent all sthpw and parent sTypes
search_type_names = schema.get_search_types(hierarchy=False)
search = Search('sthpw/search_object')
search.add_filters('search_type', search_type_names)
search_types = search.get_sobjects()
task_search_type = SearchType.get("sthpw/task")
search_types.append(task_search_type)
values = [ x.get_value("search_type") for x in search_types]
labels = []
for x in search_types:
label = "%s (%s)" % (x.get_value("title"), x.get_value("search_type"))
labels.append(label)
sobject = self.get_current_sobject()
if not sobject:
value = ""
else:
value = sobject.get_value(self.get_name() )
self.set_option("values", values)
self.set_option("labels", labels)
self.add_empty_option("-- Select --")
if value:
self.set_value(value)
return super(SearchTypeInputWdg, self).get_display()
示例5: get_display
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filters [as 别名]
def get_display(self):
sobject = self.get_current_sobject()
sobject = sobject.get_parent()
if not sobject:
return Widget()
# get all of the sobject_logs
search = Search("sthpw/sobject_log")
search.add_sobject_filter(sobject)
logs = search.get_sobjects()
search = Search("sthpw/transaction_log")
search.add_filters("id", [x.get_value("transaction_log_id") for x in logs] )
search.set_limit(200)
logs = search.get_sobjects()
from layout_wdg import TableWdg
widget = Widget()
table = TableWdg("sthpw/transaction_log")
table.add_class("minimal")
table.set_header_flag(False)
table.set_show_property(False)
table.set_no_results_wdg( " " )
table.set_sobjects(logs)
widget.add(table)
return widget
示例6: get_sobjects
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filters [as 别名]
def get_sobjects(my, connections, direction='dst', filters=None, return_search=False):
if not connections:
return []
if direction == "dst":
prefix = "dst"
else:
prefix = "src"
search_type = connections[0].get_value("%s_search_type" % prefix)
search = Search(search_type)
search_ids = [x.get_value("%s_search_id" % prefix) for x in connections]
search.add_filters("id", search_ids )
if filters:
search.add_op_filters(filters)
if return_search:
return search
sobjects = search.get_sobjects()
return sobjects
示例7: get_subscriptions
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filters [as 别名]
def get_subscriptions(my, category, mode="new"):
search = Search("sthpw/subscription")
search.add_user_filter()
if category:
search.add_filter("category", category)
if mode == "new":
search.add_op("begin")
search.add_filter("last_cleared", '"message"."timestamp"', quoted=False, op="<")
search.add_filter("last_cleared", "NULL", quoted=False, op="is")
search.add_op("or")
#project_code = Project.get_project_code()
#search.add_filter("project_code", project_code )
# use an inner join because if there are no messages, we don't
# want the subscription
search.add_order_by("message.timestamp", direction="desc", join="INNER")
# don't show user message except when category is certain values
user = Environment.get_user_name()
search.add_op("begin")
search.add_filter("login", user, op="!=", table="message")
search.add_filters("category", ["script","default","sobject"], table="message")
search.add_op("or")
else:
search.add_order_by("message.timestamp", direction="desc")
subscriptions = search.get_sobjects()
return subscriptions
示例8: get_output_tasks
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filters [as 别名]
def get_output_tasks(my):
process = my.get_value("process")
parent = my.get_parent()
# get the pipeline
pipeline_code = parent.get_value("pipeline_code", no_exception=True)
if not pipeline_code:
return []
pipeline = Pipeline.get_by_code(pipeline_code)
if not pipeline:
return []
processes = pipeline.get_output_processes(process)
if not processes:
return []
tasks = []
process_names = [x.get_name() for x in processes]
search = Search("sthpw/task")
search.add_filters("process", process_names)
search.add_parent_filter(parent)
tasks = search.get_sobjects()
return tasks
示例9: _get_sobject_history_wdg
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filters [as 别名]
def _get_sobject_history_wdg(my):
''' this method is called thru ajax '''
args = WebContainer.get_web().get_form_args()
# get the args in the URL
search_type = args['search_type']
search_id = args['search_id']
#sobject = Search.get_by_id(search_type, search_id)
div = Widget()
search = Search("sthpw/sobject_log")
search.add_filter("search_type", search_type)
search.add_filter("search_id", search_id)
sobjects = search.get_sobjects()
search = Search("sthpw/transaction_log")
search.add_filters("id", [x.get_value("transaction_log_id") for x in sobjects] )
sobjects = search.get_sobjects()
table = TableWdg("sthpw/transaction_log", "table", css='table')
table.set_show_property(False)
table.set_sobjects(sobjects)
div.add(table)
div.add(HtmlElement.br(2))
return div
div.add(assigned_shot_wdg)
div.add(HtmlElement.br(2))
return div
示例10: preprocess
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filters [as 别名]
def preprocess(my):
my.is_preprocessed = True
# get all of the instances
search = Search("prod/shot_instance")
# if not used in a TableWdg, only get the shot instances for one asset
if not my.parent_wdg:
search.add_filter('asset_code', my.get_current_sobject().get_code())
search.add_order_by("shot_code")
instances = search.get_sobjects()
my.asset_instances = instances
my.instances = {}
for instance in instances:
asset_code = instance.get_value("asset_code")
list = my.instances.get(asset_code)
if not list:
list = []
my.instances[asset_code] = list
list.append(instance)
search = Search("prod/shot")
search.add_filters( "code", [x.get_value('shot_code') for x in instances] )
shots = search.get_sobjects()
my.shots = SObject.get_dict(shots, ["code"])
my.shots_list = shots
示例11: get_tasks
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filters [as 别名]
def get_tasks(self, sobject):
search_type = SearchType.get("prod/shot").get_full_key()
# get all of the shots in the episode
shots = sobject.get_all_children("prod/shot")
ids = SObject.get_values(shots, "id")
search = Search("sthpw/task")
search.add_filter("search_type", search_type)
search.add_filters("search_id", ids)
return search.get_sobjects()
示例12: get_connections
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filters [as 别名]
def get_connections(cls, sobjects, direction="dst", context='', context_filters=[], src_search=None):
'''return a Search instance if src_search is provided'''
if not sobjects and not src_search:
return []
search = Search(SObjectConnection)
if direction == "dst":
prefix = "src"
else:
prefix = "dst"
if src_search:
search.add_filter("%s_search_type" % prefix, src_search.get_search_type() )
search.add_search_filter('%s_search_id'%prefix, src_search, op="in")
else:
search_types = [x.get_search_type() for x in sobjects]
search_ids = [x.get_id() for x in sobjects]
if len(Common.get_unique_list(search_types)) == 1:
search.add_filter("%s_search_type" % prefix, search_types[0] )
search.add_filters("%s_search_id" % prefix, search_ids)
else:
search.add_op("begin")
for search_type, search_id in zip(search_types, search_ids):
search.add_op("begin")
search.add_filter("%s_search_type" % prefix, search_type )
search.add_filter("%s_search_id" % prefix, search_id )
search.add_op("and")
search.add_op("or")
if context:
search.add_filter("context", context)
elif context_filters:
search.add_op_filters(context_filters)
if src_search:
return search
# cache for connection sobjects
key = search.get_statement()
cache = Container.get("SObjectConnection:cache")
if cache == None:
cache = {}
Container.put("SObjectConnection:cache", cache)
ret_val = cache.get(key)
if ret_val != None:
return ret_val
connections = search.get_sobjects()
return connections
示例13: get_search_types
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filters [as 别名]
def get_search_types(my, include_sthpw=False, include_config=False, include_multi_project=False):
'''get all the search types in this project'''
if my.search_types != None:
return my.search_types
project_type = my.get_value("type")
search = Search("sthpw/search_object")
project_code = my.get_code()
namespaces = [project_code]
namespaces.append(project_type)
if include_sthpw:
namespaces.append("sthpw")
if include_config:
namespaces.append("config")
if include_multi_project:
if not include_config:
search.add_filter('namespace','config',op='!=')
if not include_sthpw:
search.add_filter('namespace','sthpw',op='!=')
search.add_op('begin')
search.add_filter('database','{project}')
search.add_filters("namespace", namespaces)
if include_multi_project:
search.add_op('or')
search.add_order_by("search_type")
search_type_objs = search.get_sobjects()
"""
from pyasm.biz import Schema
schema = Schema.get()
xml = schema.get_xml_value("schema")
search_types = xml.get_values("schema/search_type/@name")
search = Search("sthpw/search_object")
search.add_filters("code", search_types)
search_type_objs = search.get_sobjects()
"""
search_types = []
for x in search_type_objs:
# to avoid the old ill-defined prod/custom_property defined in sthpw namespace
if (x.get_value('namespace') == 'sthpw' and x.get_value('search_type').find('custom_property') == -1)\
or my.has_table(x):
search_types.append(x)
return search_types
示例14: get_pipeline
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filters [as 别名]
def get_pipeline(my, pipeline_xml, add_tasks=False):
pipeline = SearchType.create("sthpw/pipeline")
pipeline.set_pipeline(pipeline_xml)
pipeline_id = random.randint(0, 10000000)
#pipeline.set_value("code", "test%s" % pipeline_id)
#pipeline.set_id(pipeline_id)
#pipeline.set_value("id", pipeline_id)
pipeline.set_value("pipeline", pipeline_xml)
pipeline.commit()
process_names = pipeline.get_process_names()
# delete the processes
search = Search("config/process")
search.add_filters("process", process_names)
processes = search.get_sobjects()
for process in processes:
process.delete()
# create new processes
processes_dict = {}
for process_name in process_names:
# define the process nodes
process = SearchType.create("config/process")
process.set_value("process", process_name)
process.set_value("pipeline_code", pipeline.get_code())
process.set_json_value("workflow", {
'on_complete': '''
sobject.set_value('%s', "complete")
''' % process_name,
'on_approve': '''
sobject.set_value('%s', "approve")
''' % process_name,
} )
process.commit()
processes_dict[process_name] = process
# Note: we don't have an sobject yet
if add_tasks:
task = SaerchType.create("sthpw/task")
task.set_parent(sobject)
task.set_value("process", process_name)
task.commit()
return pipeline, processes_dict
示例15: alter_search
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filters [as 别名]
def alter_search(self, search):
print "Introspect alter_search"
# see if any of the filters have a class handler defined
from tactic.ui.filter import FilterData
filter_data = FilterData.get_from_cgi()
values = filter_data.get_values_by_index("introspect", 0)
do_search = values.get('search')
if not do_search:
return
#search.add_filter("code", "chr002")
session = SessionContents.get()
node_names = session.get_node_names()
snapshot_codes = session.get_snapshot_codes()
snapshot_search = Search("sthpw/snapshot")
snapshot_search.add_filters("code", snapshot_codes)
snapshots = snapshot_search.get_sobjects()
state_search_type = self.kwargs.get("search_type")
# get ids
ids = []
for snapshot in snapshots:
search_type = snapshot.get_value("search_type")
if state_search_type:
search_type_obj = SearchType.get(search_type)
key = search_type_obj.get_base_key()
print "compare: ", key, state_search_type
if key != state_search_type:
continue
id = snapshot.get_value("search_id")
ids.append(id)
print "ids: ", ids
if ids:
search.add_filters("id", ids)