本文整理汇总了Python中tracim.lib.content.ContentApi.exclude_unavailable方法的典型用法代码示例。如果您正苦于以下问题:Python ContentApi.exclude_unavailable方法的具体用法?Python ContentApi.exclude_unavailable怎么用?Python ContentApi.exclude_unavailable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tracim.lib.content.ContentApi
的用法示例。
在下文中一共展示了ContentApi.exclude_unavailable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search
# 需要导入模块: from tracim.lib.content import ContentApi [as 别名]
# 或者: from tracim.lib.content.ContentApi import exclude_unavailable [as 别名]
def search(self, keywords=''):
from tracim.lib.content import ContentApi
user = tmpl_context.current_user
api = ContentApi(user)
items = []
keyword_list = api.get_keywords(keywords)
result = api.search(keyword_list)
if result:
items = result.limit(ContentApi.SEARCH_DEFAULT_RESULT_NB).all()
api.exclude_unavailable(items)
current_user_content = Context(CTX.CURRENT_USER).toDict(user)
fake_api = Context(CTX.CURRENT_USER).toDict({'current_user': current_user_content})
search_results = Context(CTX.SEARCH).toDict(items, 'results', 'result_nb')
search_results.keywords = keyword_list
return DictLikeClass(fake_api=fake_api, search=search_results)
示例2: test_unit__search_exclude_content_under_deleted_or_archived_parents__ok
# 需要导入模块: from tracim.lib.content import ContentApi [as 别名]
# 或者: from tracim.lib.content.ContentApi import exclude_unavailable [as 别名]
def test_unit__search_exclude_content_under_deleted_or_archived_parents__ok(self):
admin = DBSession.query(User).filter(User.email == '[email protected]').one()
workspace = self._create_workspace_and_test('workspace_1', admin)
folder_1 = self._create_content_and_test('folder_1', workspace=workspace, type=ContentType.Folder)
folder_2 = self._create_content_and_test('folder_2', workspace=workspace, type=ContentType.Folder)
page_1 = self._create_content_and_test('foo', workspace=workspace, type=ContentType.Page, parent=folder_1)
page_2 = self._create_content_and_test('bar', workspace=workspace, type=ContentType.Page, parent=folder_2)
api = ContentApi(admin)
foo_result = api.search(['foo']).all()
eq_(1, len(foo_result))
ok_(page_1 in foo_result)
bar_result = api.search(['bar']).all()
eq_(1, len(bar_result))
ok_(page_2 in bar_result)
with new_revision(folder_1):
api.delete(folder_1)
with new_revision(folder_2):
api.archive(folder_2)
# Actually ContentApi.search don't filter it
foo_result = api.search(['foo']).all()
eq_(1, len(foo_result))
ok_(page_1 in foo_result)
bar_result = api.search(['bar']).all()
eq_(1, len(bar_result))
ok_(page_2 in bar_result)
# ContentApi offer exclude_unavailable method to do it
foo_result = api.search(['foo']).all()
api.exclude_unavailable(foo_result)
eq_(0, len(foo_result))
bar_result = api.search(['bar']).all()
api.exclude_unavailable(bar_result)
eq_(0, len(bar_result))