本文整理汇总了Python中pyasm.biz.Project.cache_sobject方法的典型用法代码示例。如果您正苦于以下问题:Python Project.cache_sobject方法的具体用法?Python Project.cache_sobject怎么用?Python Project.cache_sobject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.biz.Project
的用法示例。
在下文中一共展示了Project.cache_sobject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register
# 需要导入模块: from pyasm.biz import Project [as 别名]
# 或者: from pyasm.biz.Project import cache_sobject [as 别名]
def register(my, name, db_resource, tables=None):
db_name = db_resource.get_database()
project_code = "db_resource/%s" % db_name
# create a virtual project
project = SearchType.create("sthpw/project")
# FIXME: what is this conflicts with an existing project
project.set_value("code", project_code)
project.set_value("db_resource", db_resource)
# put this sobject into the cache
from pyasm.biz import Project
key = "sthpw/project|%s" % project_code
Project.cache_sobject(key, project)
if tables == None:
# introspect and resister all of the tables
sql = DbContainer.get(db_resource)
table_info = sql.get_table_info()
if table_info.get("spt_search_type"):
print "has search_type"
tables = table_info.keys()
for table in tables:
# FIXME: how is this created
search_type = "table/%s?project=%s" % (table, db_name)
#search_type_obj = SearchType.create("config/search_type")
search_type_obj = SearchType.create("sthpw/search_type")
search_type_obj.set_value("search_type", "table/%s" % table)
search_type_obj.set_value("title", Common.get_display_title(table) )
search_type_obj.set_value("table_name", table)
search_type_obj.set_value("database", db_name)
SearchType.set_virtual(search_type, search_type_obj)
my.db_resources[name] = db_resource