本文整理汇总了Python中tiddlyweb.model.collections.Tiddlers.store方法的典型用法代码示例。如果您正苦于以下问题:Python Tiddlers.store方法的具体用法?Python Tiddlers.store怎么用?Python Tiddlers.store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tiddlyweb.model.collections.Tiddlers
的用法示例。
在下文中一共展示了Tiddlers.store方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_tiddlers
# 需要导入模块: from tiddlyweb.model.collections import Tiddlers [as 别名]
# 或者: from tiddlyweb.model.collections.Tiddlers import store [as 别名]
def get_tiddlers(environ, start_response):
"""
Get a list representation of the tiddlers in a
bag. The information sent is dependent on the
serialization chosen.
"""
store = environ['tiddlyweb.store']
filters = environ['tiddlyweb.filters']
bag_name = web.get_route_value(environ, 'bag_name')
bag = _get_bag(environ, bag_name)
title = 'Tiddlers From Bag %s' % bag.name
title = environ['tiddlyweb.query'].get('title', [title])[0]
usersign = environ['tiddlyweb.usersign']
# will raise exception if there are problems
bag.policy.allows(usersign, 'read')
tiddlers = Tiddlers(title=title)
if not filters:
tiddlers.store = store
tiddlers.bag = bag_name
for tiddler in store.list_bag_tiddlers(bag):
tiddlers.add(tiddler)
tiddlers.link = '%s/tiddlers' % web.bag_url(environ, bag, full=False)
return send_tiddlers(environ, start_response, tiddlers=tiddlers)
示例2: get_tiddlers
# 需要导入模块: from tiddlyweb.model.collections import Tiddlers [as 别名]
# 或者: from tiddlyweb.model.collections.Tiddlers import store [as 别名]
def get_tiddlers(environ, start_response):
"""
Get a list representation of the tiddlers in a
bag. The information sent is dependent on the
serialization chosen.
"""
store = environ["tiddlyweb.store"]
filters = environ["tiddlyweb.filters"]
bag_name = web.get_route_value(environ, "bag_name")
bag = _get_bag(environ, bag_name)
title = "Tiddlers From Bag %s" % bag.name
title = environ["tiddlyweb.query"].get("title", [title])[0]
usersign = environ["tiddlyweb.usersign"]
# will raise exception if there are problems
bag.policy.allows(usersign, "read")
tiddlers = Tiddlers(title=title)
if not filters:
tiddlers.store = store
tiddlers.bag = bag_name
# A special bag can raise NoBagError here.
try:
for tiddler in store.list_bag_tiddlers(bag):
tiddlers.add(tiddler)
except NoBagError, exc:
raise HTTP404("%s not found, %s" % (bag.name, exc))
示例3: get_tiddlers
# 需要导入模块: from tiddlyweb.model.collections import Tiddlers [as 别名]
# 或者: from tiddlyweb.model.collections.Tiddlers import store [as 别名]
def get_tiddlers(environ, start_response):
"""
Handle ``GET`` on a tiddlers-within-a-recipe URI.
Get a list representation of the :py:class:`tiddlers
<tiddlyweb.model.tiddler.Tiddler>` generated from a :py:class:`recipe
<tiddlyweb.model.recipe.Recipe>`.
The information sent is dependent on the serialization chosen
via :py:mod:`tiddlyweb.web.negotiate`.
"""
usersign = environ['tiddlyweb.usersign']
store = environ['tiddlyweb.store']
filters = environ['tiddlyweb.filters']
recipe = _determine_recipe(environ)
title = 'Tiddlers From Recipe %s' % recipe.name
title = environ['tiddlyweb.query'].get('title', [title])[0]
# check the recipe can be read
recipe.policy.allows(usersign, 'read')
# check the bags in the recipe can be read
try:
template = control.recipe_template(environ)
for bag_name, _ in recipe.get_recipe(template):
bag = Bag(bag_name)
bag = store.get(bag)
bag.policy.allows(usersign, 'read')
except NoBagError as exc:
raise HTTP404('recipe %s lists an unknown bag: %s' %
(recipe.name, exc))
# from this point forward we know the tiddlers are
# readable
# get the tiddlers from the recipe and uniquify them
try:
candidate_tiddlers = control.get_tiddlers_from_recipe(recipe, environ)
except NoBagError as exc:
raise HTTP404('recipe %s lists an unknown bag: %s' %
(recipe.name, exc))
except FilterError as exc:
raise HTTP400('malformed filter: %s' % exc)
tiddlers = Tiddlers(title=title)
if not filters:
tiddlers.store = store
tiddlers.recipe = recipe.name
for tiddler in candidate_tiddlers:
tiddler.recipe = recipe.name
tiddlers.add(tiddler)
tiddlers.link = '%s/tiddlers' % web.recipe_url(environ, recipe,
full=False)
return send_tiddlers(environ, start_response, tiddlers=tiddlers)
示例4: get_tiddlers
# 需要导入模块: from tiddlyweb.model.collections import Tiddlers [as 别名]
# 或者: from tiddlyweb.model.collections.Tiddlers import store [as 别名]
def get_tiddlers(environ, start_response):
"""
Handle ``GET`` on a tiddlers-within-a-bag URI.
Get a list representation of the :py:class:`tiddlers
<tiddlyweb.model.tiddler.Tiddler>` in a :py:class:`bag
<tiddlyweb.model.bag.Bag>`.
The information sent is dependent on the serialization chosen
via :py:mod:`tiddlyweb.web.negotiate`.
"""
store = environ['tiddlyweb.store']
filters = environ['tiddlyweb.filters']
bag_name = web.get_route_value(environ, 'bag_name')
bag = _get_bag(environ, bag_name)
title = 'Tiddlers From Bag %s' % bag.name
title = environ['tiddlyweb.query'].get('title', [title])[0]
usersign = environ['tiddlyweb.usersign']
# will raise exception if there are problems
bag.policy.allows(usersign, 'read')
tiddlers = Tiddlers(title=title)
if not filters:
tiddlers.store = store
tiddlers.bag = bag_name
# A special bag can raise NoBagError here.
try:
for tiddler in store.list_bag_tiddlers(bag):
tiddlers.add(tiddler)
except NoBagError as exc:
raise HTTP404('%s not found, %s' % (bag.name, exc))
tiddlers.link = '%s/tiddlers' % web.bag_url(environ, bag, full=False)
return send_tiddlers(environ, start_response, tiddlers=tiddlers)
示例5: HTTP404
# 需要导入模块: from tiddlyweb.model.collections import Tiddlers [as 别名]
# 或者: from tiddlyweb.model.collections.Tiddlers import store [as 别名]
# from this point forward we know the tiddlers are
# readable
# get the tiddlers from the recipe and uniquify them
try:
candidate_tiddlers = control.get_tiddlers_from_recipe(recipe, environ)
except NoBagError, exc:
raise HTTP404('recipe %s lists an unknown bag: %s' %
(recipe.name, exc))
except FilterError, exc:
raise HTTP400('malformed filter: %s' % exc)
tiddlers = Tiddlers(title=title)
if not filters:
tiddlers.store = store
tiddlers.recipe = recipe.name
for tiddler in candidate_tiddlers:
tiddler.recipe = recipe.name
tiddlers.add(tiddler)
tiddlers.link = '%s/tiddlers' % web.recipe_url(environ, recipe,
full=False)
return send_tiddlers(environ, start_response, tiddlers=tiddlers)
def list_recipes(environ, start_response):
"""
Get a list of all recipes the current user can read.