本文整理汇总了Python中pyasm.search.SObject.get_values方法的典型用法代码示例。如果您正苦于以下问题:Python SObject.get_values方法的具体用法?Python SObject.get_values怎么用?Python SObject.get_values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.search.SObject
的用法示例。
在下文中一共展示了SObject.get_values方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: preprocess
# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_values [as 别名]
def preprocess(my):
search_type_list = SObject.get_values(my.sobjects, 'search_type', unique=True)
search_id_dict = {}
my.ref_sobject_cache = {}
# initialize the search_id_dict
for type in search_type_list:
search_id_dict[type] = []
# cache it first
for sobject in my.sobjects:
search_type = sobject.get_value('search_type')
search_id_list = search_id_dict.get(search_type)
search_id_list.append(sobject.get_value('search_id'))
from pyasm.search import SearchException
for key, value in search_id_dict.items():
try:
ref_sobjects = Search.get_by_id(key, value)
sobj_dict = SObject.get_dict(ref_sobjects)
except SearchException, e:
print "WARNING: search_type [%s] with id [%s] does not exist" % (key, value)
print str(e)
sobj_dict = {}
# store a dict of dict with the search_type as key
my.ref_sobject_cache[key] = sobj_dict
示例2: get_display
# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_values [as 别名]
def get_display(my):
widget = DivWdg(id='link_view_select')
widget.add_class("link_view_select")
if my.refresh:
widget = Widget()
else:
my.set_as_panel(widget)
views = []
if my.search_type:
from pyasm.search import WidgetDbConfig
search = Search( WidgetDbConfig.SEARCH_TYPE )
search.add_filter("search_type", my.search_type)
search.add_regex_filter("view", "link_search:|saved_search:", op="NEQI")
search.add_order_by('view')
widget_dbs = search.get_sobjects()
views = SObject.get_values(widget_dbs, 'view')
labels = [view for view in views]
views.insert(0, 'table')
labels.insert(0, 'table (Default)')
st_select = SelectWdg('new_link_view', label='View: ')
st_select.set_option('values', views)
st_select.set_option('labels', labels)
widget.add(st_select)
return widget
示例3: get_display
# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_values [as 别名]
def get_display(my):
#defining init is better than get_display() for this kind of SelectWdg
search = Search( SearchType.SEARCH_TYPE )
if my.mode == None or my.mode == my.ALL_BUT_STHPW:
# always add the login / login group search types
filter = search.get_regex_filter("search_type", "login|task|note|timecard|trigger|milestone", "EQ")
no_sthpw_filter = search.get_regex_filter("search_type", "^(sthpw).*", "NEQ")
search.add_where('%s or %s' %(filter, no_sthpw_filter))
elif my.mode == my.CURRENT_PROJECT:
project = Project.get()
project_code = project.get_code()
#project_type = project.get_project_type().get_type()
project_type = project.get_value("type")
search.add_where("\"namespace\" in ('%s','%s') " % (project_type, project_code))
search.add_order_by("search_type")
search_types = search.get_sobjects()
values = SObject.get_values(search_types, 'search_type')
labels = [ x.get_label() for x in search_types ]
values.append('CustomLayoutWdg')
labels.append('CustomLayoutWdg')
my.set_option('values', values)
my.set_option('labels', labels)
#my.set_search_for_options(search, "search_type", "get_label()")
my.add_empty_option(label='-- Select Search Type --')
return super(SearchTypeSelectWdg, my).get_display()
示例4: get_mail_users
# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_values [as 别名]
def get_mail_users(my, column):
# mail groups
recipients = set()
expr = my.notification.get_value(column, no_exception=True)
if expr:
sudo = Sudo()
# Introduce an environment that can be reflected
env = {
'sobject': my.sobject
}
#if expr.startswith("@"):
# logins = Search.eval(expr, list=True, env_sobjects=env)
#else:
parts = expr.split("\n")
# go through each login and evaluate each
logins = []
for part in parts:
if part.startswith("@") or part.startswith("{"):
results = Search.eval(part, list=True, env_sobjects=env)
# clear the container after each expression eval
ExpressionParser.clear_cache()
# these can just be login names, get the actual Logins
if results:
if isinstance(results[0], basestring):
login_sobjs = Search.eval("@SOBJECT(sthpw/login['login','in','%s'])" %'|'.join(results), list=True)
login_list = SObject.get_values(login_sobjs, 'login')
for result in results:
# the original result could be an email address already
if result not in login_list:
logins.append(result)
if login_sobjs:
logins.extend( login_sobjs )
else:
logins.extend(results)
elif part.find("@") != -1:
# this is just an email address
logins.append( part )
elif part:
# this is a group
group = LoginGroup.get_by_code(part)
if group:
logins.extend( group.get_logins() )
del sudo
else:
notification_id = my.notification.get_id()
logins = GroupNotification.get_logins_by_id(notification_id)
for login in logins:
recipients.add(login)
return recipients
示例5: get_display
# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_values [as 别名]
def get_display(my):
widget = Widget()
span = SpanWdg('[ projects ]', css='hand')
span.add_style('color','white')
span.add_event('onclick',"spt.show_block('%s')" %my.WDG_ID)
widget.add(span)
# add the popup
div = DivWdg(id=my.WDG_ID, css='popup_wdg')
widget.add(div)
div.add_style('width', '80px')
div.add_style('display', 'none')
title_div = DivWdg()
div.add(title_div)
title = FloatDivWdg(' ', width='60px')
title.add_style('margin-right','2px')
title_div.add_style('padding-bottom', '4px')
title_div.add(title)
title_div.add(CloseWdg(my.get_off_script(), is_absolute=False))
div.add(HtmlElement.br())
search = Search(Project)
search.add_where("\"code\" not in ('sthpw','admin')")
search.add_column('code')
projects = search.get_sobjects()
values = SObject.get_values(projects, 'code')
web = WebContainer.get_web()
root = web.get_site_root()
security = Environment.get_security()
for value in values:
if not security.check_access("project", value, "view"):
continue
script = "location.href='/%s/%s'"%(root, value)
sub_div = DivWdg(HtmlElement.b(value), css='selection_item')
sub_div.add_event('onclick', script)
div.add(sub_div)
div.add(HtmlElement.hr())
if security.check_access("project", 'default', "view"):
script = "location.href='/%s'" % root
sub_div = DivWdg('home', css='selection_item')
sub_div.add_event('onclick', script)
div.add(sub_div)
if security.check_access("project", "admin", "view"):
script = "location.href='/%s/admin/'" %root
sub_div = DivWdg('admin', css='selection_item')
sub_div.add_event('onclick', script)
div.add(sub_div)
return widget
示例6: get_tasks
# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_values [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()
示例7: get_registered_hours
# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_values [as 别名]
def get_registered_hours(search_key, week, weekday, year, desc=None, login=None, project=None):
''' get the total registered hours for the week. ADD YEAR!!!'''
timecards = Timecard.get(search_key, week, year, desc, login, project)
hours = SObject.get_values(timecards, weekday, unique=False)
reg_hours = 0.0
for hour in hours:
if hour:
reg_hours += float(hour)
return reg_hours
示例8: preprocess
# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_values [as 别名]
def preprocess(my):
# protect against the case where there is a single sobject that
# is an insert (often seen in "insert")
if my.is_preprocessed == True:
return
skip = False
if len(my.sobjects) == 1:
if not my.sobjects[0].has_value("search_type"):
skip = True
if not skip:
search_types = SObject.get_values(my.sobjects, 'search_type', unique=True)
try:
search_codes = SObject.get_values(my.sobjects, 'search_code', unique=True)
search_ids = None
except Exception, e:
print "WARNING: ", e
search_ids = SObject.get_values(my.sobjects, 'search_id', unique=True)
search_codes = None
示例9: get_info
# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_values [as 别名]
def get_info(self):
# check if the sobj type is the same
search_types = SObject.get_values(self.sobjs, 'search_type', unique=True)
search_ids = SObject.get_values(self.sobjs, 'search_id', unique=False)
infos = []
# this doesn't really work if the same asset is submitted multiple times
if len(search_types) == 1 and len(search_ids) == len(self.sobjs):
assets = []
if search_types[0]:
assets = Search.get_by_id(search_types[0], search_ids)
asset_dict = SObject.get_dict(assets)
for id in search_ids:
asset = asset_dict.get(id)
aux_dict = {}
aux_dict['info'] = SubmissionInfo._get_target_sobject_data(asset)
aux_dict['search_key'] = '%s:%s' %(search_types[0], id)
infos.append(aux_dict)
else:
# TODO: this is a bit database intensive, mixed search_types not
# recommended
search_types = SObject.get_values(self.sobjs, 'search_type',\
unique=False)
for idx in xrange(0, len(search_types)):
search_type = search_types[idx]
aux_dict = {}
aux_dict['info'] = ''
aux_dict['search_key'] = ''
if search_type:
asset = Search.get_by_id(search_type, search_ids[idx])
aux_dict['info'] = SubmissionInfo._get_target_sobject_data(asset)
aux_dict['search_key'] = '%s:%s' %(search_types[idx], search_ids[idx])
infos.append(aux_dict)
return infos
示例10: update_process_table
# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_values [as 别名]
def update_process_table(my):
''' make sure to update process table'''
process_names = my.get_process_names()
pipeline_code = my.get_code()
search = Search("config/process")
search.add_filter("pipeline_code", pipeline_code)
process_sobjs = search.get_sobjects()
existing_names = SObject.get_values(process_sobjs, 'process')
count = 0
for process_name in process_names:
exists = False
for process_sobj in process_sobjs:
# if it already exist, then update
if process_sobj.get_value("process") == process_name:
exists = True
break
if not exists:
process_sobj = SearchType.create("config/process")
process_sobj.set_value("pipeline_code", pipeline_code)
process_sobj.set_value("process", process_name)
attrs = my.get_process_attrs(process_name)
color = attrs.get('color')
if color:
process_sobj.set_value("color", color)
process_sobj.set_value("sort_order", count)
process_sobj.commit()
count += 1
# delete obsolete
obsolete = set(existing_names) - set(process_names)
if obsolete:
for obsolete_name in obsolete:
for process_sobj in process_sobjs:
# delete it
if process_sobj.get_value("process") == obsolete_name:
process_sobj.delete()
break
示例11: postprocess
# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_values [as 别名]
def postprocess(my):
super(FlashAssetPublishCmd, my).postprocess()
# parse the introspect file
code = my.sobject.get_code()
upload_dir = my.get_upload_dir()
introspect_path = "%s/%s.xml" % (upload_dir, code)
xml = Xml()
xml.read_file(introspect_path)
flash_layer_names = xml.get_values("introspect/layers/layer/@name")
if not flash_layer_names:
return
# extract the layers from the flash layer_names
layer_names = []
for flash_layer_name in flash_layer_names:
if flash_layer_name.find(":") == -1:
continue
layer_name, instance_name = flash_layer_name.split(":")
# make sure it is unique
if layer_name not in layer_names:
layer_names.append(layer_name)
base_key = my.sobject.get_search_type_obj().get_base_key()
# TODO: make the flash shot tab run FlashShotPublishCmd instead
# and move this postprocess there
# this is not meant for flash/asset, but for flash/shot
if base_key == 'flash/asset' or not layer_names:
return
# get all of the layers in this shot and compare to the session
existing_layers = my.sobject.get_all_children("prod/layer")
existing_layer_names = SObject.get_values(existing_layers,"name")
for layer_name in layer_names:
if layer_name not in existing_layer_names:
print "creating ", layer_name
Layer.create(layer_name, code)
示例12: _get_bins
# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_values [as 别名]
def _get_bins(self):
search = Search(Bin)
# get all the types in the Bin table
type_search = Search(Bin)
type_search.add_column('type')
type_search.add_group_by('type')
types = SObject.get_values(type_search.get_sobjects(), 'type')
select = SelectWdg('display_limit')
select.set_option('persist', 'true')
display_limit = select.get_value()
if display_limit:
self.display_limit = display_limit
# by default, get 10 for each type
joined_statements = []
for type in types:
# TODO: fix this sql to run through search
select = Search('prod/bin')
select.add_filter("type", type)
select.set_show_retired(False)
select.add_order_by("code")
select.add_limit(self.display_limit)
statement = select.get_statement()
joined_statements.append(statement)
#joined_statements.append("select * from \"bin\" where \"type\" ='%s' and (\"s_status\" != 'retired' or \"s_status\" is NULL)" \
# " order by \"code\" desc limit %s" % (type, self.display_limit))
if len(joined_statements) > 1:
joined_statements = ["(%s)"%x for x in joined_statements]
statement = ' union all '.join(joined_statements)
elif len(joined_statements) == 1:
statement = joined_statements[0]
else:
# no bins created yet
return []
#print "statement: ", statement
return Bin.get_by_statement(statement)
示例13: get_tasks
# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_values [as 别名]
def get_tasks(my, sobjects=[]):
# get all of the relevant tasks to the user
task_search = Search("sthpw/task")
task_search.add_column("search_id", distinct=True)
if sobjects:
task_search.add_filter("search_type", sobjects[0].get_search_type() )
sobject_ids = SObject.get_values(sobjects, "id", unique=True)
task_search.add_filters("search_id", sobject_ids)
# only look at this project
search_type = SearchType.get(my.search_type).get_full_key()
task_search.add_filter("search_type", search_type)
my.process_filter.alter_search(task_search)
if isinstance(my.user_filter, UserFilterWdg):
my.user_filter.alter_search(task_search)
else:
user = Environment.get_user_name()
task_search.add_filter('assigned', user)
status_filters = my.task_status_filter.get_values()
if not status_filters:
return []
task_search.add_filters("status", status_filters)
tasks = task_search.get_sobjects()
return tasks
示例14: execute
# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_values [as 别名]
def execute(my):
error_list = []
from pyasm.biz import Project
Project.clear_cache()
sthpw_search = Search("sthpw/project")
sthpw_search.add_filter('code','sthpw')
sthpw_search.set_show_retired(True)
sthpw_proj = sthpw_search.get_sobject()
search = Search("sthpw/project")
if my.project_code:
search.add_filter("code", my.project_code)
else:
#search.add_enum_order_by("type", ['sthpw','prod','game','design','simple', 'unittest'])
search.add_enum_order_by("code", ['sthpw'])
projects = search.get_sobjects()
project_codes = SObject.get_values(projects, 'code')
# append sthpw project in case it's retired
if 'sthpw' not in project_codes and sthpw_proj:
if not my.project_code:
projects.insert(0, sthpw_proj)
sthpw_proj.reactivate()
current_dir = os.getcwd()
tmp_dir = Environment.get_tmp_dir()
output_file = '%s/upgrade_output.txt' % tmp_dir
if not os.path.exists(tmp_dir):
os.makedirs(tmp_dir)
elif os.path.exists(output_file):
os.unlink(output_file)
ofile = open(output_file, 'w')
import datetime
ofile.write('Upgrade Time: %s\n\n' %datetime.datetime.now())
# dynamically generate
#sql = DbContainer.get(code)
database_type = Sql.get_default_database_type()
#if database_type in ['Sqlite', 'MySQL']:
if database_type != "PostgreSQL":
# general an upgrade
import imp
namespaces = ['default', 'simple', 'sthpw', 'config']
for namespace in namespaces:
if database_type == 'Sqlite':
from pyasm.search.upgrade.sqlite import convert_sqlite_upgrade
file_path = convert_sqlite_upgrade(namespace)
elif database_type == 'MySQL':
from pyasm.search.upgrade.mysql import convert_mysql_upgrade
file_path = convert_mysql_upgrade(namespace)
elif database_type == 'SQLServer':
from pyasm.search.upgrade.sqlserver import convert_sqlserver_upgrade
file_path = convert_sqlserver_upgrade(namespace)
elif database_type == 'Oracle':
file_path = convert_oracle_upgrade(namespace)
else:
raise Exception("Database type not implemented here")
(path, name) = os.path.split(file_path)
(name, ext) = os.path.splitext(name)
(file, filename, data) = imp.find_module(name, [path])
module = imp.load_module(name, file, filename, data)
class_name = "%s%sUpgrade" % (database_type,namespace.capitalize())
exec("%s = module.%s" % (class_name, class_name) )
# load all the default modules
from pyasm.search.upgrade.project import *
for project in projects:
code = project.get_code()
if code == "sthpw":
type = "sthpw"
else:
type = project.get_type()
if not type:
type = 'default'
if not my.quiet:
print project.get_code(), type
print "-"*30
# if the project is admin, the just ignore for now
if code == 'admin':
continue
if not project.database_exists():
ofile.write("*" * 80 + '\n')
#.........这里部分代码省略.........
示例15: preprocess
# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_values [as 别名]
def preprocess(my):
'''determine if this is for EditWdg or EDIT ROW of a table'''
# get the number of task pipelines needed for EditWdg, which is one
# for the EDIT ROW , there could be more than 1
my.task_mapping = None
from tactic.ui.panel import EditWdg
if hasattr(my, 'parent_wdg') and isinstance(my.get_parent_wdg(), EditWdg):
task = my.get_current_sobject()
task_pipe_code = task.get_value('pipeline_code')
# if the current task has no pipeline, then search for
# any task pipeline
if not task_pipe_code:
# just use the default
task_pipe_code = 'task'
pipeline = Pipeline.get_by_code(task_pipe_code)
if not pipeline:
pipeline = Pipeline.get_by_code('task')
my.task_pipelines = [pipeline]
else:
# get all of the pipelines for tasks
search = Search('sthpw/pipeline')
search.add_regex_filter('search_type', 'sthpw/task')
my.task_pipelines = search.get_sobjects()
# get all of the pipelines for the current search_type
search_type = my.state.get("search_type");
search = Search('sthpw/pipeline')
if search_type:
search.add_filter('search_type', search_type)
my.sobject_pipelines = search.get_sobjects()
# insert the default task pipeline if not overridden in the db
default_task_found = False
pipeline_codes = SObject.get_values(my.task_pipelines, 'code')
if 'task' in pipeline_codes:
default_task_found = True
if not default_task_found:
default_pipe = Pipeline.get_by_code('task')
my.task_pipelines.append(default_pipe)
my.task_mapping = {}
# the following works for insert but on edit, it should read from pipeline_code attribute
for pipeline in my.sobject_pipelines:
processes = pipeline.get_process_names()
for process in processes:
attrs = pipeline.get_process_attrs(process)
task_pipeline = attrs.get('task_pipeline')
if task_pipeline:
key = '%s|%s' %(pipeline.get_code(), process)
my.task_mapping[key] = task_pipeline
#my.task_mapping = "|".join(my.task_mapping)
my.is_preprocess = True