本文整理汇总了Python中pyasm.search.Search.commit方法的典型用法代码示例。如果您正苦于以下问题:Python Search.commit方法的具体用法?Python Search.commit怎么用?Python Search.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.search.Search
的用法示例。
在下文中一共展示了Search.commit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_theme
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import commit [as 别名]
def create_theme(my, theme):
# get a built-in plugin
plugin_base_dir = Environment.get_plugin_dir()
zip_path = "%s/%s.zip" % (plugin_base_dir, theme)
manifest_path = "%s/%s/manifest.xml" % (plugin_base_dir, theme)
plugin_base_dir2 = Environment.get_builtin_plugin_dir()
zip_path2 = "%s/%s.zip" % (plugin_base_dir2, theme)
manifest_path2 = "%s/%s/manifest.xml" % (plugin_base_dir2, theme)
# install the theme
from tactic.command import PluginInstaller
if os.path.exists(manifest_path):
plugin_dir = "%s/%s" % (plugin_base_dir, theme)
installer = PluginInstaller(plugin_dir=plugin_dir, register=True)
installer.execute()
is_builtin = False
elif os.path.exists(zip_path):
installer = PluginInstaller(zip_path=zip_path, register=True)
installer.execute()
is_builtin = False
elif os.path.exists(manifest_path2):
plugin_dir = "%s/%s" % (plugin_base_dir2, theme)
installer = PluginInstaller(plugin_dir=plugin_dir, register=True)
installer.execute()
is_builtin = True
elif os.path.exists(zip_path2):
installer = PluginInstaller(zip_path=zip_path2, register=True)
installer.execute()
is_builtin = True
else:
raise Exception("Installation error: cannot find %s theme" % theme)
from pyasm.biz import PluginUtil
if is_builtin:
plugin_util = PluginUtil(base_dir=plugin_base_dir2)
else:
plugin_util = PluginUtil()
data = plugin_util.get_plugin_data(theme)
# if the theme does not have the url defined (which it likely
# shouldn't, but just in case ...
search = Search("config/url")
search.add_filter("url", "/index")
url = search.get_sobject()
if not url:
index_view = data.get("index_view")
if not index_view:
# don't use the folder in the theme
base = os.path.basename(theme)
index_view = "%s/index" % base
# set this as the default index
search = SearchType.create("config/url")
search.set_value("url", "/index")
search.set_value(
"widget",
"""
<element name='index'>
<display class='tactic.ui.panel.CustomLayoutWdg'>
<view>%s</view>
</display>
</element>
"""
% index_view,
)
search.set_value("description", "Index Page")
search.commit()