当前位置: 首页>>代码示例>>Python>>正文


Python Tiddlers.store方法代码示例

本文整理汇总了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)
开发者ID:tup,项目名称:tiddlyweb,代码行数:30,代码来源:bag.py

示例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))
开发者ID:FND,项目名称:tiddlyweb,代码行数:30,代码来源:bag.py

示例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)
开发者ID:24king,项目名称:tiddlyweb,代码行数:59,代码来源:recipe.py

示例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)
开发者ID:24king,项目名称:tiddlyweb,代码行数:39,代码来源:bag.py

示例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.
开发者ID:FND,项目名称:tiddlyweb,代码行数:32,代码来源:recipe.py


注:本文中的tiddlyweb.model.collections.Tiddlers.store方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。