本文整理汇总了Python中pyasm.search.SearchKey类的典型用法代码示例。如果您正苦于以下问题:Python SearchKey类的具体用法?Python SearchKey怎么用?Python SearchKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SearchKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check
def check(my):
if my.mode == 'export_matched':
from tactic.ui.panel import TableLayoutWdg
table = TableLayoutWdg(search_type=my.search_type, view=my.view,\
show_search_limit='false', search_limit=-1, search_view=my.search_view,\
search_class=my.search_class, simple_search_view=my.simple_search_view, init_load_num=-1)
table.handle_search()
search_objs = table.sobjects
my.selected_search_keys = SearchKey.get_by_sobjects(search_objs, use_id=True)
return True
for sk in my.input_search_keys:
st = SearchKey.extract_search_type(sk)
if st not in my.search_type_list:
my.search_type_list.append(st)
id = SearchKey.extract_id(sk)
if id == '-1':
continue
my.selected_search_keys.append(sk)
if len(my.search_type_list) > 1:
my.check_passed = False
my.error_msg = 'More than 1 search type is selected. Please keep the selection to one type only.'
return False
if not my.search_type_list and my.mode == 'export_selected':
my.check_passed = False
my.error_msg = 'Search type cannot be identified. Please select a valid item.'
return False
return True
示例2: execute
def execute(self):
self.search_key_list = self.kwargs.get('search_key_list')
web = WebContainer.get_web()
skip_duplicated = web.get_form_value('skip_duplicated') == 'on'
pipeline_mode = web.get_form_value('pipeline_mode')
sobjects = SearchKey.get_by_search_keys(self.search_key_list)
count = 0
offset = 0
for sobject in sobjects:
if isinstance(sobject, Task):
raise TacticException('Creation of task for [Task] is not allowed')
sk = SearchKey.get_by_sobject(sobject)
if not sobject.has_value('pipeline_code'):
#raise TacticException('Creation of task is not allowed for item with no pipeline_code attribute.')
pipeline_code = '__default__'
sobject.set_value("pipeline_code", pipeline_code)
else:
pipeline_code = sobject.get_value('pipeline_code')
input_name = '%s|task_process'% pipeline_code
contexts = []
process_names = web.get_form_values(input_name)
process_names = [name for name in process_names if name]
if pipeline_mode == 'context':
# when pipeline_mode is context, we only specify contexts
# in add_initial_tasks
contexts = process_names[:]
process_names = []
tasks = Task.add_initial_tasks(sobject, sobject.get_value('pipeline_code'),
processes=process_names, contexts=contexts, skip_duplicate=skip_duplicated, mode=pipeline_mode, start_offset=offset)
count += len(tasks)
offset += 5
self.add_description("%s Tasks added in total." % count)
示例3: get_display
def get_display(my):
my.context = ''
sobject = my.get_current_sobject()
if sobject.get_base_search_type() in ['sthpw/task', 'sthpw/note']:
my.process = sobject.get_value('process')
my.context = sobject.get_value('context')
if not my.process:
my.process = ''
sobject_mode = my.kwargs.get("sobject_mode")
if not sobject_mode:
sobject_mode = "parent"
#sobject_mode = "connect"
if sobject_mode == "parent":
parent = sobject.get_parent()
elif sobject_mode == "connect":
parent = Search.eval("@SOBJECT(connect)", sobject, single=True)
elif sobject_mode == "expression":
expression = "???"
parent = Search.eval("@SOBJECT(connect)", sobject, single=True)
else:
parent = sobject
if not parent:
return DivWdg()
search_key = SearchKey.get_by_sobject(parent)
else:
my.process = my.get_option('process')
if not my.process:
my.process = "publish"
search_key = SearchKey.get_by_sobject(sobject)
#my.behavior['process'] = my.process
#my.behavior['context'] = my.context
#my.behavior['search_key'] = search_key
# set the atrs
div = super(CheckinButtonElementWdg, my).get_display()
div.add_attr("spt_process", my.process)
div.add_attr("spt_context", my.context)
div.add_attr("spt_search_key", search_key)
return div
示例4: add_header
def add_header(self, table, title):
table.add_style('width', '50em')
parent_st = self.kwargs.get('parent_search_type')
parent_sid = self.kwargs.get('parent_search_id')
parent_context = ''
parent_version = ''
sobj = Search.get_by_id(parent_st, parent_sid)
sobj_code = 'New'
sobj_title = ''
if sobj:
sobj_code = sobj.get_code()
sobj_title = sobj.get_search_type_obj().get_title()
if isinstance(sobj, Snapshot):
parent_context = sobj.get_context()
parent_version = sobj.get_version()
th = table.add_header( "Add Submission for %s [%s]" % (sobj_title, sobj_code))
th.set_attr("colspan", "2")
hidden = HiddenWdg('parent_search_type', parent_st )
th.add(hidden)
hidden = HiddenWdg('parent_search_id', parent_sid )
th.add(hidden)
hidden = HiddenWdg('parent_context', parent_context )
th.add(hidden)
hidden = HiddenWdg('parent_version', parent_version )
th.add(hidden)
if sobj:
hidden = HiddenWdg('parent_search_key', SearchKey.get_by_sobject(sobj) )
th.add(hidden)
示例5: get_files
def get_files(my):
paths = []
# remember this here for now
my.files = {}
my.snapshots = {}
search_key = my.kwargs.get("search_key")
search_keys = my.kwargs.get("search_keys")
if search_key:
sobject = SearchKey.get_by_search_key(search_key)
my.sobjects = [sobject]
if search_keys:
if isinstance(search_keys, basestring):
search_keys = search_keys.replace("'", '"')
search_keys = jsonloads(search_keys)
my.sobjects = Search.get_by_search_keys(search_keys)
if not my.sobjects:
return []
my.sobject = my.sobjects[0]
for sobject in my.sobjects:
sobject_paths = my.get_sobject_files(sobject)
paths.extend(sobject_paths)
return paths
示例6: get_section_wdg
def get_section_wdg(my, sobject):
parent_key = SearchKey.get_by_sobject(sobject)
section_id = "wow"
title = ""
view = "children"
target_id = "sobject_relation"
kwargs = {
'section_id': section_id,
'title': title,
'view': view,
'target_id': target_id,
'width': '125',
'parent_key': parent_key
}
section_div = DivWdg()
section_div.add_style("display: block")
section_div.set_id(section_id)
section_div.set_attr('spt_class_name', "tactic.ui.panel.ChildrenBookmarkMenuWdg")
for name, value in kwargs.items():
if name == "config":
continue
section_div.set_attr("spt_%s" % name, value)
section_wdg = SObjectChildrenMenuWdg(**kwargs)
section_div.add(section_wdg)
return section_div
示例7: execute
def execute(my):
#my.snapshot_dict = {}
web = WebContainer.get_web()
shot_code = web.get_form_value("shot_code")
search = Search(my.search_type)
search.add_filter('code', shot_code)
shot = search.get_sobject()
#shot = Shot.get_by_code(shot_code)
is_current = web.get_form_value("currency")
if is_current in ['True', 'on']:
is_current = True
else:
is_current = False
is_revision = web.get_form_value("checkin_as")
if is_revision == "Version":
is_revision = False
else:
is_revision = True
checkin_status = web.get_form_value("checkin_status")
checkin = ShotCheckin(shot)
checkin.set_option("unknown_ref", web.get_form_value("unknown_ref"))
checkin.set_process(my.process)
description = web.get_form_value("%s_description" % shot.get_code() )
checkin.set_context(my.context)
checkin.set_description(description)
checkin.set_current(is_current)
checkin.set_revision(is_revision)
use_handoff_dir = web.get_form_value("use_handoff_dir")
if use_handoff_dir in ['true','on']:
checkin.set_use_handoff(True)
checkin.execute()
snapshot = checkin.snapshot
version = snapshot.get_version()
my.sobjects = [shot]
#my.snapshot_dict['%s' %shot.get_code()] = snapshot
my.add_description("%s checkin '%s': v%0.3d, %s" % (my.context, shot.get_code(), version, description))
web.set_form_value('publish_search_type','prod/shot')
TabWdg.set_redirect('Log')
my.info['context'] = my.context
my.info['revision'] = str(is_revision)
my.info['checkin_status'] = checkin_status
output = {'context': my.context}
output['search_key'] = SearchKey.build_by_sobject(shot)
output['checkin_status'] = checkin_status
Trigger.call(my, 'app_checkin', output)
示例8: get_display
def get_display(my):
div = DivWdg()
sobject = my.get_current_sobject()
search_key = SearchKey.get_by_sobject(sobject)
if sobject.is_admin():
return "ADMIN"
icon = IconButtonWdg("Global Permissions", IconWdg.EDIT)
icon.add_behavior( {
"type": "click_up",
"cbjs_action": "spt.popup.get_widget(evt, bvr)",
"options": {
"class_name": "tactic.ui.panel.SecurityManagerWdg",
"title": "Permisssion Manager",
"popup_id": "Permission Manager"
},
"args": {
"search_key": search_key
}
} )
div.add(icon)
return div
示例9: handle_td
def handle_td(self, td):
sobject = self.get_current_sobject()
parent = None
if sobject.is_insert():
parent_key = self.state.get('parent_key')
if parent_key:
parent = SearchKey.get_by_search_key(parent_key)
else:
try:
parent = sobject.get_parent()
except SObjectSecurityException as e:
pass
except SearchException as e:
if e.__str__().find('not registered') != -1:
pass
elif e.__str__().find('does not exist for database') != -1:
pass
else:
raise
process = sobject.get_value('process')
current_value = sobject.get_value(self.get_name())
if current_value:
value = '%s||%s'%(process, current_value)
td.add_attr("spt_input_value", value)
if parent:
td.set_attr("spt_pipeline_code", parent.get_value("pipeline_code", no_exception=True))
示例10: get_ref_obj
def get_ref_obj(self, sobject):
search_type = sobject.get_value("search_type")
search_code = sobject.get_value("search_code", no_exception=True)
if not search_code:
search_id = sobject.get_value("search_code")
else:
search_id = None
key = SearchKey.build_search_key(search_type, search_code)
ref_sobject = self.ref_sobj_dict.get(str(key))
if not ref_sobject:
try:
if search_code:
ref_sobject = Search.get_by_code(search_type, search_code)
else:
ref_sobject = Search.get_by_id(search_type, search_id)
if not ref_sobject:
return None
except SearchException as e:
print e.__str__()
return None
return ref_sobject
示例11: handle_td
def handle_td(self, td):
sobj = self.get_current_sobject()
parent = None
value = sobj.get_value('process')
td.add_attr('spt_input_value', value)
if sobj.is_insert():
state = self.get_state()
parent_key = state.get('parent_key')
if parent_key:
parent = SearchKey.get_by_search_key(parent_key)
else:
# get the parent pipeline code
try:
parent = sobj.get_parent()
except SObjectSecurityException as e:
print "SObjectSecurityException raised for getting parent of [%s]" %sobj.get_code()
pass
except SearchException as e:
if e.__str__().find('not registered') != -1:
pass
elif e.__str__().find('does not exist for database') != -1:
pass
else:
raise
except Exception as e:
print "WARNING: ", e
if parent:
pipeline_code = parent.get_value("pipeline_code", no_exception=True)
if pipeline_code:
td.add_attr('spt_pipeline_code', pipeline_code)
示例12: get_action_html
def get_action_html(my):
search_key = SearchKey.get_by_sobject(my.sobjects[0])
behavior_submit = {
'type': 'click_up',
'cb_fire_named_event': 'append_pressed',
'element_names': my.element_names,
'search_key': search_key,
'input_prefix': my.input_prefix
}
behavior_cancel = {
'type': 'click_up',
'cb_fire_named_event': 'preclose_edit_popup',
'cbjs_postaction': "spt.popup.destroy( spt.popup.get_popup( $('edit_popup') ) );"
}
button_list = [{'label': "%s/Close" % my.mode.capitalize(),
'bvr': behavior_submit},
{'label': "Cancel", 'bvr': behavior_cancel}]
edit_close = TextBtnSetWdg( buttons=button_list, spacing =6, size='large', \
align='center',side_padding=10)
div = DivWdg()
div.add_styles('height: 35px; margin-top: 10px;')
div.center()
div.add(edit_close)
return div
示例13: init_cache
def init_cache(self):
'''initialize the cache'''
self.mtime = datetime.datetime.now()
keys = self.caches.keys()
self.caches = {}
search = Search(self.search_type)
search.set_show_retired(True)
self.sobjects = search.get_sobjects()
# build a search_key cache
search_key_cache = {}
search_keys = SearchKey.get_by_sobjects(self.sobjects)
for search_key, sobject in zip(search_keys, self.sobjects):
search_key_cache[search_key] = sobject
self.caches['search_key'] = search_key_cache
code_cache = {}
for sobject in self.sobjects:
code = sobject.get_code()
code_cache[code] = sobject
self.caches['code'] = code_cache
for key in keys:
if key in ['search_key', 'code']:
continue
self.build_cache_by_column(key)
示例14: postprocess
def postprocess(self):
web = WebContainer.get_web()
value = web.get_form_value( self.get_input_name() )
if not value:
return
# get all fo the sobjects from the search keys
instance_type = self.get_option("instance_type")
# path is used for self-relating in an instance table
src_path = self.get_option("path")
#src_sobject = self.sobject
search = Search(self.sobject.get_search_type())
search.add_id_filter(self.sobject.get_id())
src_sobject = search.get_sobject()
# this is passed in from EditCmd in insert mode
parent_key = self.get_option('parent_key')
# in some rare cases we have project as the parent_key
if parent_key and self.is_insert and 'sthpw/project' not in parent_key:
# this is the parent
dst_sobject = SearchKey.get_by_search_key(parent_key)
# add all the new sobjects
#instances = dst_sobject.get_related_sobject(instance_type)
instance = SearchType.create(instance_type)
instance.add_related_connection(src_sobject, dst_sobject, src_path=src_path)
instance.commit()
示例15: check
def check(my):
search_key = my.kwargs.get('search_key')
my.sobject = SearchKey.get_by_search_key(search_key)
from pyasm.web import WebContainer
web = WebContainer.get_web()
my.old_password = web.get_form_value("old password")
if isinstance(my.old_password, list):
my.old_password = my.old_password[0]
#encrypted = md5.new(my.old_password).hexdigest()
encrypted = hashlib.md5(my.old_password).hexdigest()
if encrypted != my.sobject.get_value('password'):
raise UserException('Old password is incorrect.')
my.password = web.get_form_value("password")
if isinstance(my.password, list):
my.password = my.password[0]
if my.sobject == None:
return UserException("Current user cannot be determined.")
my.re_enter = web.get_form_value("password re-enter")
if isinstance(my.re_enter, list):
my.re_enter = my.re_enter[0]
if my.re_enter != "" and my.re_enter != my.password:
raise UserException( "Passwords must match. Please fill in the re-enter.")
return True