本文整理汇总了Python中pyasm.search.Search.add_filter方法的典型用法代码示例。如果您正苦于以下问题:Python Search.add_filter方法的具体用法?Python Search.add_filter怎么用?Python Search.add_filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.search.Search
的用法示例。
在下文中一共展示了Search.add_filter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filter [as 别名]
def main(server=None, input_data=None):
if not input_data:
input_data = {}
if not server:
server = TacticServerStub.get()
input_sobject = input_data.get('sobject')
order_code = input_sobject.get('code')
priority = input_sobject.get('priority')
component_search = Search('twog/component')
component_search.add_filter('order_code', order_code)
component_sobjects = component_search.get_sobjects()
for component_sobject in component_sobjects:
tasks = get_task_sobjects_from_component_sobject(component_sobject)
data_to_insert = {}
for task in tasks:
task_search_key = server.build_search_key('sthpw/task', task.get_code(), project_code='twog')
data_to_insert[task_search_key] = {'priority': priority}
server.update_multiple(data_to_insert)
开发者ID:2gDigitalPost,项目名称:custom-rewrite,代码行数:29,代码来源:match_task_priority_with_order_priority_on_change.py
示例2: execute
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filter [as 别名]
def execute(my):
view = my.kwargs.get("view")
content = my.kwargs.get("content")
search = Search("config/widget_config")
search.add_filter("category", "HelpWdg")
search.add_filter("view", view)
config = search.get_sobject()
if not config:
config = SearchType.create("config/widget_config")
config.set_value("category", "HelpWdg")
config.set_value("view", view)
config_xml = '''
<config>
<%s>
<html><div><![CDATA[
%s
]]></div></html>
</%s>
</config>
''' % (view, content, view)
config.set_value("config", config_xml)
config.commit()
示例3: get_client_img
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filter [as 别名]
def get_client_img(client_code):
img_path = ''
client_search = Search("twog/client")
client_search.add_filter('code', client_code)
client_search_object = client_search.get_sobject()
if client_search_object:
client_id = client_search_object.get_id()
snaps_s = Search("sthpw/snapshot")
snaps_s.add_filter('search_id', client_id)
snaps_s.add_filter('search_type', 'twog/client?project=twog')
snaps_s.add_filter('is_current', '1')
snaps_s.add_filter('version', '0', op='>')
snaps_s.add_where("\"context\" in ('publish','icon','MISC')")
snaps_s.add_order_by('timestamp desc')
snaps = snaps_s.get_sobjects()
if len(snaps) > 0:
server = TacticServerStub.get()
snap = snaps[0]
img_path = server.get_path_from_snapshot(snap.get_code(), mode="web")
if img_path:
img_path = 'http://' + server.get_server_name() + img_path
return img_path
else:
return None
示例4: _test_task
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filter [as 别名]
def _test_task(my):
project = Project.get()
# create a new task
task = SearchType.create("sthpw/task")
task.set_parent(project)
task.set_value("code", "XXX001")
task.set_value("process", "unittest")
task.set_value("description", "unittest")
# set a time with no timezone. A timestamp with no timezone should
# assume GMT.
test_time = '2011-11-11 00:00:00'
task.set_value("timestamp", test_time)
# asset that the time has not changed
timestamp = task.get_value("timestamp")
my.assertEquals(timestamp, test_time)
task.commit()
# get the task back from the databse
search = Search("sthpw/task")
search.add_filter("code", "XXX001")
task = search.get_sobject()
# make sure the time has not changed. This value should is assumed
# to be in GMT
timestamp = task.get_value("timestamp")
my.assertEquals(timestamp, test_time)
task.delete()
示例5: get_by_search_type
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filter [as 别名]
def get_by_search_type(cls, search_type, project_code=''):
# make sure this is a be search type
assert search_type
search_type_obj = SearchType.get(search_type)
if not search_type_obj:
return []
search_type = search_type_obj.get_base_key()
cache_key = "%s|%s" % (search_type, project_code)
# commenting out until we have a full implementation of
# project pipelines
"""
search = Search("config/pipeline")
if search_type:
search.add_filter("search_type", search_type)
search.add_project_filter(project_code)
pipelines = cls.get_by_search(search, cache_key, is_multi=True)
"""
search = Search("sthpw/pipeline")
if search_type:
search.add_filter("search_type", search_type)
search.add_project_filter(project_code)
pipelines = cls.get_by_search(search, cache_key, is_multi=True)
if not pipelines:
return []
for pipe in pipelines:
code = pipe.get_code()
cls.cache_sobject('sthpw/pipeline|%s' %code, pipe)
return pipelines
示例6: init
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filter [as 别名]
def init(my):
from pyasm.common import Environment
from pyasm.search import Search
my.login = Environment.get_login()
my.user = my.login.get_login()
my.sk = ''
my.seen_groups = []
my.bigdict = {}
my.indi_pct = 0.0
my.stat_colors = {'Pending':'#d7d7d7','In Progress':'#f5f3a4','In_Progress':'#f5f3a4','On Hold':'#e8b2b8','On_Hold':'#e8b2b8','Client Response': '#ddd5b8', 'Completed':'#b7e0a5','Need Buddy Check':'#e3701a','Ready':'#b2cee8','Internal Rejection':'#ff0000','External Rejection':'#ff0000','Fix Needed':'#c466a1','Failed QC':'#ff0000','Rejected': '#ff0000','DR In_Progress': '#d6e0a4', 'DR In Progress': '#d6e0a4','Amberfin01_In_Progress':'#D8F1A8', 'Amberfin01 In Progress':'#D8F1A8','Amberfin02_In_Progress':'#F3D291', 'Amberfin02 In Progress':'#F3D291','BATON In_Progress': '#c6e0a4', 'BATON In Progress': '#c6e0a4','Export In_Progress': '#796999','Export In Progress': '#796999', 'Buddy Check In_Progress': '#1aade3','Buddy Check In Progress': '#1aade3'}
my.stat_relevance = {'Pending': 0,'In Progress': 4,'In_Progress': 4,'On Hold': 1,'On_Hold': 1,'Client Response': 2, 'Completed': -1,'Need Buddy Check': 10, 'Buddy Check In_Progress': 11, 'Buddy Check In Progress': 11, 'Ready': 3,'Internal Rejection': 12,'External Rejection': 13,'Failed QC': 14,'Fix Needed': 16,'Rejected': 15,'DR In_Progress': 5, 'DR In Progress': 5,'BATON In_Progress': 8, 'BATON In Progress': 8,'Export In_Progress': 9, 'Export In Progress': 9,'Amberfin01_In_Progress': 6, 'Amberfin01 In Progress': 6, 'Amberfin02_In_Progress':7, 'Amberfin02 In Progress':7 }
my.timestamp = my.make_timestamp()
my.date = my.timestamp.split(' ')[0]
my.real_date = datetime.datetime.strptime(my.date, '%Y-%m-%d')
my.all_groups = []
my.big_user = False
users_s = Search('sthpw/login')
users_s.add_filter('location','internal')
users = users_s.get_sobjects()
my.username_lookup = {'': '', None: '', 'NOTHING': ''}
for user in users:
login_name = user.get_value('login')
fname = user.get_value('first_name')
lname = user.get_value('last_name')
my.username_lookup[login_name] = '%s %s' % (fname, lname)
示例7: check_existing_jobs
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filter [as 别名]
def check_existing_jobs(self):
self.keep_jobs = []
for job in self.jobs:
job_code = job.get_code()
search = Search(self.get_job_search_type())
search.add_filter("code", job_code)
job = search.get_sobject()
if not job:
print("Cancel ....")
scheduler = Scheduler.get()
scheduler.cancel_task(job_code)
continue
state = job.get_value("state")
if state == 'cancel':
print("Cancel task [%s] ...." % job_code)
scheduler = Scheduler.get()
scheduler.cancel_task(job_code)
job.set_value("state", "terminated")
job.commit()
continue
self.keep_jobs.append(job)
self.jobs = self.keep_jobs
示例8: get_deliverable_files_in_order
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filter [as 别名]
def get_deliverable_files_in_order(order_sobject):
"""
Given an order sobject, return all the deliverable files associated with it.
:param order_sobject: twog/order sobject
:return: List of twog/file sobjects
"""
files_in_order_search = Search('twog/file_in_order')
files_in_order_search.add_filter('order_code', order_sobject.get_code())
files_in_order = files_in_order_search.get_sobjects()
if files_in_order:
files_in_order_string = ','.join(
["'{0}'".format(files_in_order.get('file_code')) for files_in_order in files_in_order]
)
deliverable_files_search = Search('twog/file')
deliverable_files_search.add_where('\"code\" in ({0})'.format(files_in_order_string))
deliverable_files_search.add_filter('classification', 'deliverable')
deliverable_files = deliverable_files_search.get_sobjects()
return deliverable_files
else:
return []
示例9: execute
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filter [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()
示例10: execute
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filter [as 别名]
def execute(my):
my.collection_key = my.kwargs.get("collection_key")
collection = Search.get_by_search_key(my.collection_key)
collection_code = collection.get("code")
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())
items = search.get_sobjects()
for item in items:
item.delete()
# Also need to delete the asset_in_asset relationships in its parent collections
parent_search = Search(collection_type)
parent_search.add_filter("search_code", collection.get_code())
parent_items = parent_search.get_sobjects()
for parent_item in parent_items:
parent_item.delete()
collection.delete()
my.add_description("Remove Collection [%s]" % collection_code)
示例11: get_task_estimated_hours_from_package_task_code
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filter [as 别名]
def get_task_estimated_hours_from_package_task_code(task_code):
"""
From a sthpw/task sobject, assumed to be attached to a twog/package, get the estimated hours for the task.
This is taken from the twog/platform_connection sobject related to the package.
:param task_code: sthpw/task code (must be for a twog/package)
:return: Float
"""
# Get the task sobject
task = get_sobject_by_code('sthpw/task', task_code)
# Get the package sobject
package = task.get_parent()
# Get the platform code, used for the platform_connection search
platform_code = package.get('platform_code')
# Get the division code, also for the platform_connection search
division = get_client_division_sobject_from_order_code(package.get('order_code'))
division_code = division.get_code()
# Search for the platform_connection
platform_connection_search = Search('twog/platform_connection')
platform_connection_search.add_filter('platform_code', platform_code)
platform_connection_search.add_filter('division_code', division_code)
platform_connection = platform_connection_search.get_sobject()
# Get the estimated hours, and convert to a float
estimated_hours = float(platform_connection.get('estimated_hours'))
return estimated_hours
示例12: _test_cache
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filter [as 别名]
def _test_cache(self):
from pyasm.common import Config
Config.set_value("security", "mode", "cache", no_exception=True)
#Config.set_value("security", "authenticate_class", "pyasm.security.authenticate_test.AutocreateAuthenticate", no_exception=True)
Config.set_value("security", "authenticate_class", "pyasm.security.mms_authenticate.MMSAuthenticate", no_exception=True)
mode = Config.get_value("security", "authenticate_class", use_cache=False)
mode = Config.get_value("security", "mode", use_cache=False)
self.assertEquals(mode, "cache")
# verify that the user exists in the database
search = Search("sthpw/login")
search.add_filter("login", "foofoo")
login = search.get_sobject()
self.assertEquals(None, login)
from pyasm.search import Transaction
transaction = Transaction.get(create=True)
transaction.start()
self.security.login_user("foofoo", "wow")
# verify that the user exists in the database
search = Search("sthpw/login")
search.add_filter("login", "foofoo")
login = search.get_sobject()
self.assertNotEquals(None, login)
示例13: update_related
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filter [as 别名]
def update_related(self, login_group, prev_login_group):
'''Update related table login_in_group'''
search = Search('sthpw/login_in_group')
search.add_filter('login_group', prev_login_group)
login_in_groups = search.get_sobjects()
if login_in_groups:
server = TacticServerStub.get()
login_in_group_dict = {}
data = {
"login_group": login_group
}
for login_in_group in login_in_groups:
login_in_group_code = login_in_group.get("code")
login_in_group_sk = server.build_search_key("sthpw/login_in_group", login_in_group_code)
login_in_group_dict[login_in_group_sk] = data
try:
server.update_multiple(login_in_group_dict)
except Exception, e:
raise TacticException('Error updating login_in_group %s' % e.str())
示例14: setUp
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filter [as 别名]
def setUp(my):
# start batch environment
Batch()
from pyasm.web.web_init import WebInit
WebInit().execute()
my.sample3d_env = Sample3dEnvironment(project_code='sample3d')
my.sample3d_env.create()
my.test_env = UnittestEnvironment()
my.test_env.create()
# set up the proper project_type, with the use the ProdDirNaming and ProdFileNaming
search = Search('sthpw/project')
search.add_filter('code', 'unittest')
my.sobj = search.get_sobject()
# store the original setting in your database
my.original_proj_type_dict = {'dir_naming_cls': my.sobj.get_value('dir_naming_cls'),
'file_naming_cls': my.sobj.get_value('file_naming_cls') }
#my.transaction = Transaction.get(create=True)
if my.sobj:
my.sobj.set_value('dir_naming_cls', 'pyasm.prod.biz.ProdDirNaming')
my.sobj.set_value('file_naming_cls', 'pyasm.prod.biz.ProdFileNaming')
my.sobj.commit()
else:
my.sobj = SearchType.create('sthpw/project_type')
my.sobj.set_value('dir_naming_cls', 'pyasm.prod.biz.ProdDirNaming')
my.sobj.set_value('file_naming_cls', 'pyasm.prod.biz.ProdFileNaming')
my.sobj.set_value('code', 'unittest')
my.sobj.commit()
示例15: handle_config2
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_filter [as 别名]
def handle_config2(my):
"""for db column search config stuff, not used yet"""
web = WebContainer.get_web()
search_type = "SearchTypeSchema"
view = "definition"
config_search_type = "config/widget_config"
search = Search(config_search_type)
search.add_filter("search_type", search_type)
search.add_filter("view", view)
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)
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_data_type = web.get_form_value("config_data_type")
if config_data_type == "Other...":
config_data_type = web.get_form_value("config_data_type_custom")
config_nullable = web.get_form_value("config_nullable")
# 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, "data_type", config_data_type)
Xml.set_attribute(node, "nullable", config_nullable)
Xml.set_attribute(node, "new", "True")
config_string = config_xml.to_string(node)
else:
config_string = """
<element name="%s" data_type="%s" nullable="%s" new="True"/>
""" % (
my.element_name,
config_data_type,
config_nullable,
)
config.append_xml_element(my.element_name, config_string)
config.commit_config()