本文整理汇总了Python中tiddlyweb.model.bag.Bag.store方法的典型用法代码示例。如果您正苦于以下问题:Python Bag.store方法的具体用法?Python Bag.store怎么用?Python Bag.store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tiddlyweb.model.bag.Bag
的用法示例。
在下文中一共展示了Bag.store方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_filter_bag_by_filter
# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import store [as 别名]
def test_filter_bag_by_filter():
"""
Confirm a bag will properly filter.
"""
bagfour = Bag('bagfour')
store.put(bagfour)
bagfour.store = store
for tiddler in tiddlers:
tiddler.bag = 'bagfour'
store.put(tiddler)
filtered_tiddlers = list(control._filter_tiddlers_from_bag(bagfour,
'select=title:TiddlerOne', environ=environ))
assert len(filtered_tiddlers) == 1
assert filtered_tiddlers[0].title == 'TiddlerOne'
filtered_tiddlers = list(control._filter_tiddlers_from_bag(bagfour,
'select=tag:tagone', environ=environ))
assert len(filtered_tiddlers) == 2
filters, thing = parse_for_filters(
'select=tag:tagone;select=title:TiddlerThree', environ=environ)
filtered_tiddlers = list(control._filter_tiddlers_from_bag(bagfour,
filters, environ=environ))
assert len(filtered_tiddlers) == 1
assert filtered_tiddlers[0].title == 'TiddlerThree'
示例2: get_tiddlers_from_recipe
# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import store [as 别名]
def get_tiddlers_from_recipe(recipe, environ=None):
"""
Return the list of tiddlers that result from processing the recipe.
This list of tiddlers is unique by title with tiddlers later in the
recipe taking precedence over those earlier in the recipe.
The tiddlers returned are empty objects.
"""
template = recipe_template(environ)
store = recipe.store
uniquifier = {}
for bag, filter_string in recipe.get_recipe(template):
if isinstance(bag, basestring):
bag = Bag(name=bag)
bag.store = store
for tiddler in _filter_tiddlers_from_bag(bag, filter_string, environ=environ):
uniquifier[tiddler.title] = tiddler
return uniquifier.values()