本文整理汇总了Python中pyasm.biz.Schema.get方法的典型用法代码示例。如果您正苦于以下问题:Python Schema.get方法的具体用法?Python Schema.get怎么用?Python Schema.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.biz.Schema
的用法示例。
在下文中一共展示了Schema.get方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_display
# 需要导入模块: from pyasm.biz import Schema [as 别名]
# 或者: from pyasm.biz.Schema import get [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()
示例2: get_related_types
# 需要导入模块: from pyasm.biz import Schema [as 别名]
# 或者: from pyasm.biz.Schema import get [as 别名]
def get_related_types(self, search_type):
# find all the relationships
schema = Schema.get()
related_types = schema.get_related_search_types(search_type)
parent_type = schema.get_parent_type(search_type)
child_types = schema.get_child_types(search_type)
# some special considerations
# FIXME: this needs to be more automatic. Should only be
# deletable children (however, that will be defined)
if search_type in ['sthpw/task','sthpw/note', 'sthpw/snapshot']:
if "sthpw/project" in related_types:
related_types.remove("sthpw/project")
if "sthpw/login" in related_types:
related_types.remove("sthpw/login")
if "config/process" in related_types:
related_types.remove("config/process")
if parent_type in related_types:
related_types.remove(parent_type)
related_types.append('sthpw/note')
related_types.append('sthpw/task')
related_types.append('sthpw/snapshot')
related_types.append('sthpw/work_hour')
related_types.append('sthpw/pipeline')
related_types.append('sthpw/sobject_list')
return related_types
示例3: get_hier_sel
# 需要导入模块: from pyasm.biz import Schema [as 别名]
# 或者: from pyasm.biz.Schema import get [as 别名]
def get_hier_sel(my, search_type):
sel = SelectWdg(my.RELATED_SEARCH_TYPE, label='Related Search Type: ')
sel.add_empty_option()
schema = Schema.get()
search_type_list = [search_type]
if schema:
parent_search_type = schema.get_parent_type(search_type)
if parent_search_type:
search_type_list.append(parent_search_type)
child_types = schema.get_child_types(search_type)
search_type_list.extend(child_types)
sel.set_option('values', search_type_list)
sel.set_value(my.related_search_type)
return sel
示例4: init
# 需要导入模块: from pyasm.biz import Schema [as 别名]
# 或者: from pyasm.biz.Schema import get [as 别名]
def init(my):
my.schema = Schema.get()
if not my.schema:
my.parent_type = None
my.select = None
return
web = WebContainer.get_web()
my.search_type = web.get_form_value("filter|search_type")
if not my.search_type:
search_type = my.options.get("search_type")
my.parent_type = my.schema.get_parent_type(my.search_type)
if not my.parent_type:
my.select = None
else:
my.select = FilterSelectWdg("filter|%s" % my.parent_type)
示例5: _test_relationship
# 需要导入模块: from pyasm.biz import Schema [as 别名]
# 或者: from pyasm.biz.Schema import get [as 别名]
def _test_relationship(my):
search_type = "table/posts?project=mongodb"
search_type2 = "table/posts2?project=mongodb"
from pyasm.biz import Schema
schema = Schema.get()
relationship = schema.get_relationship(search_type, search_type2)
my.assertEquals(None, relationship)
search_type2 = "sthpw/task"
relationship = schema.get_relationship(search_type, search_type2)
my.assertEquals("search_id", relationship)
attrs = schema.get_relationship_attrs(search_type, search_type2)
my.assertEquals("*", attrs.get("to") )
my.assertEquals("search_type", attrs.get("relationship") )
示例6: get_display
# 需要导入模块: from pyasm.biz import Schema [as 别名]
# 或者: from pyasm.biz.Schema import get [as 别名]
def get_display(my):
#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]
filtered = []
labels = []
for x in search_types:
base_type = x.get_base_key()
exists = SearchType.column_exists(base_type, "pipeline_code")
if not exists:
continue
label = "%s (%s)" % (x.get_value("title"), x.get_value("search_type"))
labels.append(label)
filtered.append(base_type)
values = filtered
sobject = my.get_current_sobject()
if not sobject:
value = ""
else:
value = sobject.get_value(my.get_name() )
my.set_option("values", values)
my.set_option("labels", labels)
my.add_empty_option("-- Select --")
if value:
my.set_value(value)
return super(SearchTypeWithPipelineInputWdg, my).get_display()
示例7: execute
# 需要导入模块: from pyasm.biz import Schema [as 别名]
# 或者: from pyasm.biz.Schema import get [as 别名]
def execute(self):
# if a single sobject is passed in
sobject = self.kwargs.get("sobject")
if not sobject:
search_key = self.kwargs.get("search_key")
sobject = Search.get_by_search_key(search_key)
if sobject:
sobjects = [sobject]
else:
search_keys = self.kwargs.get("search_keys")
sobjects = Search.get_by_search_keys(search_keys)
if not sobjects:
return
# find all the relationships
self.schema = Schema.get()
for sobject in sobjects:
self.delete_sobject(sobject)
示例8: import_manifest
# 需要导入模块: from pyasm.biz import Schema [as 别名]
# 或者: from pyasm.biz.Schema import get [as 别名]
def import_manifest(my, nodes):
paths_read = []
for node in nodes:
node_name = my.xml.get_node_name(node)
if node_name == 'search_type':
search_type = my.xml.get_attribute(node, 'code')
# implicitly add the entry to the schema table.
# Reset the cache every time to ensure that any updates to
# the scehma are reflected here.
schema = Schema.get(reset_cache=True)
xml = schema.get_xml()
schema_node = xml.get_node("schema/search_type[@name='%s']" % search_type)
parent = xml.get_node("schema")
if schema_node == None:
schema_node = xml.create_element("search_type")
xml.set_attribute(schema_node, "name", search_type)
#parent = xml.get_parent(node)
xml.append_child(parent, schema_node)
schema.set_value('schema', xml.to_string() )
schema.commit()
# TODO: connections?
path = my.xml.get_attribute(node, "path")
if not path:
path = "%s.spt" % search_type.replace("/", "_")
path = "%s/%s" % (my.plugin_dir, path)
if path in paths_read:
continue
if my.verbose:
print "Reading search_type: ", path
# NOTE: priviledged knowledge of the order or return values
jobs = my.import_data(path, commit=True)
paths_read.append(path)
if not jobs:
continue
search_type_obj = jobs[0]
if len(jobs) == 1:
# only the search type was defined
table = None
else:
table = jobs[1]
try:
# check to see if the search type already exists
search_type_chk = SearchType.get(search_type)
if search_type_chk:
if my.verbose:
print 'WARNING: Search Type [%s] is already registered' % search_type_chk.get_value("search_type")
else:
search_type_obj.commit()
except SearchException, e:
if e.__str__().find('not registered') != -1:
search_type_obj.commit()
# check if table exists
has_table = False
if has_table:
if my.verbose:
print 'WARNING: Table [%s] already exists'
elif table:
#print table.get_statement()
if table:
database = table.get_database()
table_name = table.get_table()
TableUndo.log(search_type, database, table_name)
elif node_name == 'sobject':
path = my.xml.get_attribute(node, "path")
search_type = my.xml.get_attribute(node, "search_type")
seq_max = my.xml.get_attribute(node, "seq_max")
try:
if seq_max:
seq_max = int(seq_max)
except ValueError:
seq_max = 0
if not path:
if search_type:
path = "%s.spt" % search_type.replace("/","_")
if not path:
raise TacticException("No path specified")
#.........这里部分代码省略.........
示例9: get_display
# 需要导入模块: from pyasm.biz import Schema [as 别名]
# 或者: from pyasm.biz.Schema import get [as 别名]
def get_display(my):
top = my.top
my.set_as_panel(top)
top.add_class("spt_delete_top")
top.add_color("background", "background")
top.add_color("color", "color")
top.add_border()
top.add_style("width: 300px")
top.add_border()
search_key = my.kwargs.get("search_key")
search_keys = my.kwargs.get("search_keys")
if search_key:
sobject = Search.get_by_search_key(search_key)
sobjects = [sobject]
search_keys = [search_key]
elif search_keys:
sobjects = Search.get_by_search_keys(search_keys)
sobject = sobjects[0]
if not sobjects:
msg = "%s not found" %search_key
return msg
search_type = sobject.get_base_search_type()
if search_type in ['sthpw/project', 'sthpw/search_object']:
msg = 'You cannot delete these items with this tool'
return msg
my.search_keys = search_keys
title = DivWdg()
top.add(title)
title.add_color("background", "background", -10)
if my.search_keys:
title.add("Delete %s Items" % len(my.search_keys))
else:
title.add("Delete Item [%s]" % (sobject.get_code()))
title.add_style("font-size: 14px")
title.add_style("font-weight: bold")
title.add_style("padding: 10px")
content = DivWdg()
top.add(content)
content.add_style("padding: 10px")
content.add("The item to be deleted has a number of dependencies as described below:<br/>", 'heading')
# find all the relationships
schema = Schema.get()
related_types = schema.get_related_search_types(search_type, direction="children")
parent_type = schema.get_parent_type(search_type)
child_types = schema.get_child_types(search_type)
# some special considerations
# FIXME: this needs to be more automatic. Should only be
# deletable children (however, that will be defined)
if search_type in ['sthpw/task','sthpw/note', 'sthpw/snapshot']:
if "sthpw/project" in related_types:
related_types.remove("sthpw/project")
if "sthpw/login" in related_types:
related_types.remove("sthpw/login")
if "config/process" in related_types:
related_types.remove("config/process")
if parent_type in related_types:
related_types.remove(parent_type)
related_types.append('sthpw/note')
related_types.append('sthpw/task')
related_types.append('sthpw/snapshot')
if 'sthpw/work_hour' not in related_types:
related_types.append('sthpw/work_hour')
items_div = DivWdg()
content.add( items_div )
items_div.add_style("padding: 10px")
valid_related_ctr = 0
for related_type in related_types:
if related_type == "*":
print "WARNING: related_type is *"
continue
if related_type == search_type:
continue
if related_type in ['sthpw/search_object','sthpw/search_type']:
continue
item_div = my.get_item_div(sobjects, related_type)
if item_div:
items_div.add(item_div)
valid_related_ctr += 1
#.........这里部分代码省略.........
示例10: get_by_sobjects
# 需要导入模块: from pyasm.biz import Schema [as 别名]
# 或者: from pyasm.biz.Schema import get [as 别名]
def get_by_sobjects(sobjects, process=None, order=True):
if not sobjects:
return []
# quickly go through the sobjects to determine if their search types
# are the same
multi_stypes = False
for sobject in sobjects:
if sobject.get_search_type() != sobjects[0].get_search_type():
multi_stypes = True
break
search = Search( Task.SEARCH_TYPE )
if multi_stypes:
# sort this into a dictionary and make multiple calls to
# search.add_relationship_filters
# use the first sobject as a sample
sobjects_dict = {}
for sobject in sobjects:
st = sobject.get_search_type()
sobj_list = sobjects_dict.get(st)
if sobj_list == None:
sobjects_dict[st] = [sobject]
else:
sobj_list.append(sobject)
search.add_op('begin')
for key, sobj_list in sobjects_dict.items():
search.add_op('begin')
search.add_relationship_filters(sobj_list)
search.add_op('and')
search.add_op('or')
else:
from pyasm.biz import Schema
schema = Schema.get()
# FIXME: why doesn't the ops work here?
filters = []
search.add_relationship_filters(sobjects)
"""
for sobject in sobjects:
search_type = sobject.get_search_type()
attrs = schema.get_relationship_attrs("sthpw/task", search_type)
attrs = schema.resolve_relationship_attrs(attrs, "sthpw/task", search_type)
search_code = sobject.get_value(attrs.get("to_col"))
#search_code = sobject.get_value("code")
#search.add_filter('search_type', search_type)
#search.add_filter('search_id', search_id, quoted=False)
#search.add_op("and")
if attrs.get("from_col") == "search_code":
filters.append("search_type = '%s' and search_code = '%s'" % (search_type, search_code))
else:
filters.append("search_type = '%s' and search_id = %s" % (search_type, search_code))
search.add_where(" or ".join(filters))
"""
search.add_order_by("search_type")
search.add_order_by("search_code")
search.add_order_by("search_id")
# get the pipeline of the sobject
pipeline = Pipeline.get_by_sobject(sobject)
if order:
if pipeline:
process_names = pipeline.get_process_names(True)
search.add_enum_order_by("process", process_names)
else:
search.add_order_by("process")
search.add_order_by("id")
if process:
if isinstance(process, basestring):
search.add_filter("process", process)
else:
search.add_filters("process", process)
tasks = search.get_sobjects()
return tasks
示例11: init
# 需要导入模块: from pyasm.biz import Schema [as 别名]
# 或者: from pyasm.biz.Schema import get [as 别名]
def init(my):
my.is_refresh = my.kwargs.get("refresh")
my.search_key = my.kwargs.get("search_key")
my.ticket_key = my.kwargs.get("ticket")
my.parent_key = my.kwargs.get("parent_key")
my.expression = my.kwargs.get("expression")
# This assumed parent can cause errors as it tries to find a
# relationship between to stypes that don't exist ... or worse,
# try to bind them when one stype does not have the sufficent columns
# ie: pipeline_code
#if not my.parent_key:
# project = Project.get()
# my.parent_key = project.get_search_key()
my.code = my.kwargs.get("code")
sobject = None
if my.search_key:
sobject = Search.get_by_search_key(my.search_key)
my.search_id = sobject.get_id()
my.search_type = sobject.get_base_search_type()
if sobject.is_insert():
my.mode = 'insert'
else:
my.mode = 'edit'
elif my.expression:
sobject = Search.eval(my.expression, single=True)
my.search_id = sobject.get_id()
my.search_type = sobject.get_base_search_type()
my.mode = 'edit'
elif my.ticket_key:
from pyasm.security import Ticket, Login
ticket = Ticket.get_by_valid_key(my.ticket_key)
if not ticket:
raise TacticException("No valid ticket")
login_code = ticket.get_value("login")
login = Login.get_by_code(login_code)
my.search_type = "sthpw/login"
my.search_id = login.get_id()
my.mode = 'edit'
elif my.code:
my.search_type = my.kwargs.get("search_type")
search = Search(my.search_type)
search.add_filter("code", my.code)
sobject = search.get_sobject()
my.search_id = sobject.get_id()
my.search_type = sobject.get_base_search_type()
my.mode = 'edit'
else:
my.search_type = my.kwargs.get("search_type")
my.search_id = my.kwargs.get("search_id")
if not my.search_id:
my.search_id = -1
my.search_id = int(my.search_id)
if my.search_id != -1:
my.mode = "edit"
else:
my.mode = "insert"
# explicit override
if my.kwargs.get("mode"):
my.mode = my.kwargs.get("mode")
my.view = my.kwargs.get("view")
if not my.view:
my.view = my.kwargs.get("config_base")
if not my.view:
my.view = "edit"
default_data = my.kwargs.get('default')
if not default_data:
default_data = {}
elif isinstance(default_data, basestring):
try:
default_data = jsonloads(default_data)
except:
#may be it's regular dictionary
try:
default_data = eval(default_data)
except:
print "Warning: Cannot evaluate [%s]" %default_data
default_data = {}
if sobject:
my.set_sobjects([sobject], None)
else:
my.do_search()
#.........这里部分代码省略.........
示例12: get_display
# 需要导入模块: from pyasm.biz import Schema [as 别名]
# 或者: from pyasm.biz.Schema import get [as 别名]
def get_display(my):
sobject = my.get_current_sobject()
sobj_name = sobject.get_name()
search_type = sobject.get_search_type_obj()
stype_title = search_type.get_title()
from pyasm.biz import Schema
schema = Schema.get()
related_types = schema.get_related_search_types(search_type.get_base_key())
related_types = ",".join(related_types)
name = my.get_name()
top = DivWdg()
top.add_attr("spt_related_types", related_types)
top.add_style("min-width: 250px")
if sobject.is_insert():
top.add_style("opacity: 0.3")
else:
# this gives the swap it's behaviors, so will be disabled
# on insert
top.add_class("spt_hidden_row_%s" % name)
my.set_option("label", "{}%s" % (sobj_name))
label = my.get_option("label")
if label:
label = Search.eval(label, sobject)
else:
label = None
if not label:
label = sobject.get_code()
icon = my.get_option("icon")
icon = "DETAILS"
#from pyasm.widget import ThumbWdg
#thumb_div = DivWdg()
#thumb = ThumbWdg()
#thumb_div.add(thumb)
#thumb.set_sobject(search_type)
#thumb.set_option("icon_size", "16")
#thumb_div.add_style("float: left")
#thumb_div.add_style("width: 22px")
title = DivWdg()
#title.add(thumb_div)
title.add(label)
stype_div = SpanWdg(" (%s)" % stype_title)
title.add(stype_div)
stype_div.add_style("opacity: 0.3")
stype_div.add_style("font-syle: italic")
stype_div.add_style("font-size: 9px")
#swap = SwapDisplayWdg(title=label, icon=icon)
swap = SwapDisplayWdg(title=title, icon=icon)
swap.set_behavior_top(my.layout)
swap.add_style("float: left")
swap.add_class("spt_level_listen")
top.add(swap)
return top