本文整理汇总了Python中tiddlyweb.model.recipe.Recipe.desc方法的典型用法代码示例。如果您正苦于以下问题:Python Recipe.desc方法的具体用法?Python Recipe.desc怎么用?Python Recipe.desc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tiddlyweb.model.recipe.Recipe
的用法示例。
在下文中一共展示了Recipe.desc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_recipe_etag
# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import desc [as 别名]
def test_recipe_etag():
"""
Explicitly test recipe_etag method (not used by the core code).
"""
recipe1 = Recipe('foo')
recipe1.desc = 'desc'
recipe2 = Recipe('foo')
recipe2.desc = 'desc'
assert recipe_etag(environ, recipe1) == recipe_etag(environ, recipe2)
示例2: _create_recipe
# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import desc [as 别名]
def _create_recipe(environ):
"""Take the form input and turn it into a recipe."""
# get bag_names before we flatten because it will be a list
bag_names = environ['tiddlyweb.query'].get('bags', [])
query_data = _flatten_form_data(environ['tiddlyweb.query'])
store = environ['tiddlyweb.store']
try:
new_recipe_name = query_data['recipe_name']
if _recipe_exists(store, new_recipe_name):
raise HTTP409('That recipe may not be created.')
new_recipe = Recipe(new_recipe_name)
username = environ['tiddlyweb.usersign']['name']
new_recipe.policy.owner = username
new_recipe.policy.manage = [username]
new_recipe.desc = query_data.get('recipe_desc', '')
privacy = query_data['privacy']
new_recipe.policy.read = _policy_form_to_entry(username, privacy)
bag_list = []
if query_data.get('autowiki', 0):
bag_list.extend(AUTOWIKI_BAGS)
# don't worry about default content bag yet
bag_list.extend(bag_names)
recipe_list = [[bag_name, ''] for bag_name in bag_list]
new_recipe.set_recipe(recipe_list)
store.put(new_recipe)
except KeyError, exc:
raise HTTP400('something went wrong processing for: %s' % exc)
示例3: test_recipe_bad_filter_400
# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import desc [as 别名]
def test_recipe_bad_filter_400():
recipe = Recipe('badfilter')
recipe.desc = u'hello'
recipe.set_recipe([('bag8', 'select=error:5')])
store.put(recipe)
response, content = http.requestU(
'http://our_test_domain:8001/recipes/badfilter/tiddlers')
assert response['status'] == '400', content
示例4: test_recipe_bad_filter_400
# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import desc [as 别名]
def test_recipe_bad_filter_400():
recipe = Recipe("badfilter")
recipe.desc = u"hello"
recipe.set_recipe([("bag8", "select=error:5")])
store.put(recipe)
http = httplib2.Http()
response, content = http.request("http://our_test_domain:8001/recipes/badfilter/tiddlers")
assert response["status"] == "400", content
示例5: test_store_recipe
# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import desc [as 别名]
def test_store_recipe():
recipe_in = Recipe('recipeone')
recipe_in.desc = 'recipe description'
store.put(recipe_in)
recipe_out = store.get(Recipe('recipeone'))
assert recipe_out.name == recipe_in.name
示例6: test_recipe_has_description
# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import desc [as 别名]
def test_recipe_has_description():
"""
Confirm a recipe can set and use a description.
"""
recipe = Recipe('hasbeen', desc='monkey puzzle')
assert recipe.name == 'hasbeen'
assert recipe.desc == 'monkey puzzle'
recipe.desc = 'collapsing sideburns'
assert recipe.desc == 'collapsing sideburns'
示例7: test_recipe_no_recipe
# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import desc [as 别名]
def test_recipe_no_recipe():
"""
make a sure a recipe that is stored without a recipe is retrievable
"""
recipe = Recipe('testrecipe2')
recipe.desc = 'I enjoy being stored'
store.put(recipe)
stored_recipe = Recipe('testrecipe2')
stored_recipe = store.get(stored_recipe)
assert stored_recipe.desc == recipe.desc
示例8: test_recipe_delete
# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import desc [as 别名]
def test_recipe_delete():
recipe = Recipe('deleteme')
recipe.desc = 'delete me please'
store.put(recipe)
stored_recipe = Recipe('deleteme')
stored_recipe = store.get(stored_recipe)
assert stored_recipe.desc == 'delete me please'
deleted_recipe = Recipe('deleteme')
store.delete(deleted_recipe)
py.test.raises(NoRecipeError, 'store.get(deleted_recipe)')
py.test.raises(NoRecipeError, 'store.delete(deleted_recipe)')
示例9: test_recipe_put
# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import desc [as 别名]
def test_recipe_put():
"""
put a recipe to disk and make sure it is there.
"""
recipe = Recipe('testrecipe')
recipe.desc = 'I enjoy being stored'
recipe.set_recipe(recipe_list_string)
store.put(recipe)
if type(store.storage) != tiddlyweb.stores.text.Store:
py.test.skip('skipping this test for non-text store')
assert os.path.exists(expected_stored_filename)
示例10: test_get_recipe_dot_name
# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import desc [as 别名]
def test_get_recipe_dot_name():
"""
Effectively return an entity with a dot in the name.
"""
recipe = Recipe("long.gif")
recipe.desc = u"hello"
store.put(recipe)
http = httplib2.Http()
response, content = http.request("http://our_test_domain:8001/recipes/long.gif", method="GET")
assert response["status"] == "200"
store.delete(recipe)
示例11: test_store_recipe
# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import desc [as 别名]
def test_store_recipe():
recipe = Recipe('recipe1')
recipe.desc = 'recipe 1 desc'
recipe.set_recipe([
['bag1', '']
])
store.put(recipe)
assert os.path.exists('store/recipe1.recipe')
loaded_recipe = Recipe('recipe1')
loaded_recipe = store.get(loaded_recipe)
assert loaded_recipe.desc == recipe.desc
示例12: test_get_recipe_dot_name
# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import desc [as 别名]
def test_get_recipe_dot_name():
"""
Effectively return an entity with a dot in the name.
"""
recipe = Recipe('long.gif')
recipe.desc = u'hello'
store.put(recipe)
response, content = http.requestU(
'http://our_test_domain:8001/recipes/long.gif',
method='GET')
assert response['status'] == '200'
store.delete(recipe)
示例13: test_recipes
# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import desc [as 别名]
def test_recipes():
store.put(Bag('alpha'))
store.put(Bag('beta'))
tiddler = Tiddler('steak', 'alpha')
tiddler.text = 'rare'
store.put(tiddler)
tiddler = Tiddler('liver', 'beta')
tiddler.text = 'icky'
store.put(tiddler)
tiddler = Tiddler('steak', 'beta')
tiddler.text = 'medium'
store.put(tiddler)
recipec = Recipe('cow')
recipec.desc = 'a meaty melange'
recipec.policy.accept.append('cdent')
recipec.set_recipe([
('alpha', 'select=tag:systemConfig'),
('beta', '')])
store.put(recipec)
recipes = list(store.list_recipes())
assert len(recipes) == 1
reciped = store.get(recipes[0])
assert reciped.name == recipec.name
assert reciped.desc == recipec.desc
recipe_list = reciped.get_recipe()
assert recipe_list[0] == ['alpha', 'select=tag:systemConfig']
assert recipe_list[1] == ['beta', '']
tiddlers = list(get_tiddlers_from_recipe(reciped, environ=environ))
assert len(tiddlers) == 2
for tiddler in tiddlers:
assert tiddler.bag == 'beta'
if tiddler.title == 'alpha':
tiddler = store.get(tiddler)
assert tiddler.text == 'medium'
store.delete(reciped)
recipes = list(store.list_recipes())
assert len(recipes) == 0
示例14: post_createrecipe
# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import desc [as 别名]
def post_createrecipe(environ, start_response):
user = get_user_object(environ)
store = environ['tiddlyweb.store']
recipe_name = environ['tiddlyweb.query'].get('recipe', [''])[0]
bag_name = environ['tiddlyweb.query'].get('bag', [''])[0]
publicity = environ['tiddlyweb.query'].get('publicity', [''])[0]
description = environ['tiddlyweb.query'].get('description', [''])[0]
if not bag_name or not recipe_name:
raise HTTP400('missing data')
recipe = Recipe(recipe_name)
bag = Bag(bag_name)
try:
recipe = store.get(recipe)
raise HTTP400('recipe exists')
except NoRecipeError:
pass
try:
bag.skinny = True
bag = store.get(bag)
try:
bag.policy.allows(user, 'read')
except (UserRequiredError, ForbiddenError):
raise HTTP400('bag not readable')
except NoBagError:
bag.policy.owner = user['name']
for constraint in ['read', 'write', 'create', 'delete', 'manage']:
setattr(bag.policy, constraint, [user['name']])
store.put(bag)
if publicity == 'private':
recipe.policy.read = [user['name']]
else:
recipe.policy.read = []
recipe.policy.manage = [user['name']]
recipe.policy.owner = user['name']
recipe.desc = description
recipe.set_recipe([
('system', ''),
(bag.name, ''),
])
store.put(recipe)
raise HTTP303('%s/home' % server_base_url(environ))
示例15: test_recipe_put
# 需要导入模块: from tiddlyweb.model.recipe import Recipe [as 别名]
# 或者: from tiddlyweb.model.recipe.Recipe import desc [as 别名]
def test_recipe_put():
"""
put a recipe to disk and make sure it is there.
"""
recipe = Recipe("testrecipe")
recipe.desc = "I enjoy being stored"
recipe.set_recipe(recipe_list_string)
store.put(recipe)
if type(store.storage) != tiddlyweb.stores.text.Store:
py.test.skip("skipping this test for non-text store")
assert os.path.exists(expected_stored_filename)
with open(expected_stored_filename) as f:
content = f.read()
if sys.version_info[0] < 3:
assert content == expected_stored_content