本文整理汇总了Python中tiddlyweb.model.bag.Bag.gen_tiddlers方法的典型用法代码示例。如果您正苦于以下问题:Python Bag.gen_tiddlers方法的具体用法?Python Bag.gen_tiddlers怎么用?Python Bag.gen_tiddlers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tiddlyweb.model.bag.Bag
的用法示例。
在下文中一共展示了Bag.gen_tiddlers方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: determine_tiddler_bag_from_recipe
# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import gen_tiddlers [as 别名]
def determine_tiddler_bag_from_recipe(recipe, tiddler, environ=None):
"""
We have a recipe and a tiddler. We need to
know the bag in which this tiddler can be found.
This is different from determine_bag_for_tiddler().
That one finds the bag the tiddler _could_ be in.
This is the bag the tiddler _is_ in.
We reverse the recipe_list, and filter each bag
according to the rule. Then we look in the list of
tiddlers and see if ours is in there.
"""
store = recipe.store
template = _recipe_template(environ)
for bag, filter_string in reversed(recipe.get_recipe(template)):
if isinstance(bag, basestring):
bag = Bag(name=bag)
if store:
bag = store.get(bag)
# If there is a filter_string then we need to load the tiddlers off
# the store. If there's not, then we can just use the list that is
# already in the bag, saving a bit of time.
if filter_string:
for candidate_tiddler in filter_tiddlers_from_bag(bag,
filter_string):
if tiddler.title == candidate_tiddler.title:
return bag
else:
for candidate_tiddler in bag.gen_tiddlers():
if tiddler.title == candidate_tiddler.title:
return bag
raise NoBagError('no suitable bag for %s' % tiddler.title)
示例2: retrieve_from_store
# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import gen_tiddlers [as 别名]
def retrieve_from_store(email):
"""
get the tiddler requested by the email from the store
and return it as an email
"""
store = get_store(config)
tiddler_title = clean_subject(email["subject"])
tiddler = Tiddler(tiddler_title)
bag = determine_bag(email["to"])
tiddler.bag = bag
try:
tiddler = store.get(tiddler)
response_text = tiddler.text
except NoTiddlerError:
# Tiddler not found. Return a list of all tiddlers
bag = Bag(bag)
bag = store.get(bag)
response_text = "The following tiddlers are in %s:\n" % email["to"].split("@")[1]
tiddlers = bag.gen_tiddlers()
tiddlers = [tiddler for tiddler in tiddlers]
response_text += "\n".join([tiddler.title for tiddler in tiddlers])
response_email = {"from": email["to"], "to": email["from"], "subject": tiddler.title, "body": response_text}
return response_email
示例3: check_bag
# 需要导入模块: from tiddlyweb.model.bag import Bag [as 别名]
# 或者: from tiddlyweb.model.bag.Bag import gen_tiddlers [as 别名]
def check_bag(tiddler, store, bag_names):
"""
check that the tiddler is not in the listed bags
"""
for bag_name in bag_names:
bag = Bag(bag_name)
bag = store.get(bag)
tiddlers = bag.gen_tiddlers()
if tiddler.title in [reserved.title for reserved in tiddlers]:
raise InvalidTiddlerError('Tiddler name is reserved: %s' \
% tiddler.title)