本文整理汇总了Python中tiddlyweb.model.recipe.Recipe.store方法的典型用法代码示例。如果您正苦于以下问题:Python Recipe.store方法的具体用法?Python Recipe.store怎么用?Python Recipe.store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tiddlyweb.model.recipe.Recipe
的用法示例。
在下文中一共展示了Recipe.store方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_in_a_recipe
# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import store [as 别名]
def test_in_a_recipe():
from tiddlyweb.config import config
store = get_store(config)
bag = Bag('hi')
store.put(bag)
tiddler = Tiddler('thing1', 'hi')
tiddler.tags = ['research']
store.put(tiddler)
tiddler = Tiddler('thing2', 'hi')
store.put(tiddler)
recipe1 = Recipe('oi')
recipe1.set_recipe([('hi', 'mselect=tag:research')])
recipe1.store = store
recipe2 = Recipe('coi')
recipe2.set_recipe([('hi', 'select=tag:research')])
recipe2.store = store
recipe3 = Recipe('boi')
recipe3.set_recipe([('hi', '')])
recipe3.store = store
environ = {'tiddlyweb.store': store}
tiddlers = list(control.get_tiddlers_from_recipe(recipe1, environ))
assert len(tiddlers) == 1
tiddlers = list(control.get_tiddlers_from_recipe(recipe2, environ))
assert len(tiddlers) == 1
tiddlers = list(control.get_tiddlers_from_recipe(recipe3, environ))
assert len(tiddlers) == 2
示例2: test_index_query_in_recipe
# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import store [as 别名]
def test_index_query_in_recipe():
config['indexer'] = 'test.indexernot'
bag = Bag('noop')
store.put(bag)
tiddler = Tiddler('dwell', 'noop')
store.put(tiddler)
recipe = Recipe('coolio')
recipe.set_recipe([('noop', u''), ('fwoop', u'')])
recipe.store = store
tiddler = Tiddler('swell')
py.test.raises(ImportError,
'determine_bag_from_recipe(recipe, tiddler, environ)')
config['indexer'] = 'test.indexer'
bag = determine_bag_from_recipe(recipe, tiddler, environ)
assert bag.name == 'fwoop'
tiddler = Tiddler('dwell')
bag = determine_bag_from_recipe(recipe, tiddler, environ)
assert bag.name == 'noop'
tiddler = Tiddler('carnaby') # nowhere
py.test.raises(NoBagError,
'determine_bag_from_recipe(recipe, tiddler, environ)')
示例3: test_bag_object_in_recipe
# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import store [as 别名]
def test_bag_object_in_recipe():
bag = Bag('fwoop')
store.put(bag)
tiddler = Tiddler('swell', 'fwoop')
tiddler.text = 'hi'
store.put(tiddler)
recipe = Recipe('heyo')
recipe.set_recipe([(bag, '')])
recipe.store = store
tiddlers = list(get_tiddlers_from_recipe(recipe, environ))
assert len(tiddlers) == 1
assert tiddlers[0].title == 'swell'
assert tiddlers[0].bag == 'fwoop'
示例4: user_page
# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import store [as 别名]
def user_page(environ, start_response):
print(environ)
name = environ['wsgiorg.routing_args'][1].get('name', 'default')
recipe = Recipe('tmp')
recipe.set_recipe([
[name, '']
])
# establish the store on the recipe so that get_tiddlers_from_recipe
# will load the bags and their tiddler lists from the store
recipe.store = environ['tiddlyweb.store']
tiddlers = control.get_tiddlers_from_recipe(recipe, environ)
bag = Bag('tmp', tmpbag=True)
bag.add_tiddlers(tiddlers)
return send_tiddlers(environ, start_response, bag)
示例5: test_recipe_with_special
# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import store [as 别名]
def test_recipe_with_special():
recipe = Recipe('special')
recipe.set_recipe([
('normal', ''),
('Xnine', '')])
recipe.store = store
tiddlers = list(get_tiddlers_from_recipe(recipe, environ))
assert len(tiddlers) == 4
assert 'thing' in [tiddler.title for tiddler in tiddlers]
assert 'alpha' in [tiddler.title for tiddler in tiddlers]
assert 'beta' in [tiddler.title for tiddler in tiddlers]
assert 'gamma' in [tiddler.title for tiddler in tiddlers]
# roundtrip the recipes with a special
store.put(recipe)
recipe2 = store.get(Recipe('special'))
assert recipe.get_recipe() == recipe2.get_recipe()
示例6: test_list_recipe_tiddlers
# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import store [as 别名]
def test_list_recipe_tiddlers():
bag = Bag('alpha')
STORE.put(bag)
recipe = Recipe('omega')
recipe.set_recipe([('alpha', '')])
recipe.store = STORE
STORE.put(recipe)
for title in ['Foo', 'Bar', 'Baz']:
tiddler = Tiddler(title, bag.name)
STORE.put(tiddler)
initialize_app(STORE.environ['tiddlyweb.config'])
http = httplib2.Http()
response, content = (http.
request('http://example.org:8001/recipes/omega/tiddlers.json',
method='GET'))
for tiddler in json.loads(content):
assert tiddler["recipe"] == recipe.name
示例7: create_dynamic_recipe
# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import store [as 别名]
def create_dynamic_recipe(environ,recipeDefinition):
recipe = Recipe('myRecipe')
recipe.set_recipe(recipeDefinition)
recipe.store = environ['tiddlyweb.store']
return recipe