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


Python Space.list_recipes方法代码示例

本文整理汇总了Python中tiddlywebplugins.tiddlyspace.space.Space.list_recipes方法的典型用法代码示例。如果您正苦于以下问题:Python Space.list_recipes方法的具体用法?Python Space.list_recipes怎么用?Python Space.list_recipes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tiddlywebplugins.tiddlyspace.space.Space的用法示例。


在下文中一共展示了Space.list_recipes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _handle_dropping_privs

# 需要导入模块: from tiddlywebplugins.tiddlyspace.space import Space [as 别名]
# 或者: from tiddlywebplugins.tiddlyspace.space.Space import list_recipes [as 别名]
    def _handle_dropping_privs(self, environ, req_uri):
        """
        Determin if this request is to be considered "in space" or
        not. If it is not and the current user is not GUEST we need
        to pretend that the current user is GUEST, effectively
        "dropping" privileges.
        """
        if environ['tiddlyweb.usersign']['name'] == 'GUEST':
            return

        http_host, _ = determine_host(environ)
        space_name = determine_space(environ, http_host)

        if space_name is None:
            return

        space = Space(space_name)

        container_name = req_uri.split('/')[2]

        if (req_uri.startswith('/bags/')
                and self._valid_bag(environ, space, container_name)):
            return

        if (req_uri.startswith('/recipes/')
                and container_name in space.list_recipes()):
            return

        self._drop_privs(environ)
        return
开发者ID:Alanchi,项目名称:tiddlyspace,代码行数:32,代码来源:controlview.py

示例2: _handle_dropping_privs

# 需要导入模块: from tiddlywebplugins.tiddlyspace.space import Space [as 别名]
# 或者: from tiddlywebplugins.tiddlyspace.space.Space import list_recipes [as 别名]
    def _handle_dropping_privs(self, environ, req_uri):
        if environ['tiddlyweb.usersign']['name'] == 'GUEST':
            return

        http_host, _ = determine_host(environ)
        space_name = determine_space(environ, http_host)

        if space_name == None:
            return

        space = Space(space_name)

        store = environ['tiddlyweb.store']
        container_name = req_uri.split('/')[2]

        if req_uri.startswith('/bags/'):
            recipe_name = determine_space_recipe(environ, space_name)
            space_recipe = store.get(Recipe(recipe_name))
            template = recipe_template(environ)
            recipe_bags = [bag for bag, _ in space_recipe.get_recipe(template)]
            recipe_bags.extend(space.extra_bags())
            if environ['REQUEST_METHOD'] == 'GET':
                if container_name in recipe_bags:
                    return
                if container_name in ADMIN_BAGS:
                    return
            else:
                base_bags = space.list_bags()
                # add bags in the recipe which may have been added
                # by the recipe mgt. That is: bags which are not
                # included and not core.
                acceptable_bags = [bag for bag in recipe_bags if not (
                    Space.bag_is_public(bag) or Space.bag_is_private(bag)
                    or Space.bag_is_associate(bag))]
                acceptable_bags.extend(base_bags)
                acceptable_bags.extend(ADMIN_BAGS)
                if container_name in acceptable_bags:
                    return

        if (req_uri.startswith('/recipes/')
                and container_name in space.list_recipes()):
            return

        self._drop_privs(environ)
        return
开发者ID:Erls-Corporation,项目名称:tiddlyspace,代码行数:47,代码来源:controlview.py

示例3: test_list_recipes

# 需要导入模块: from tiddlywebplugins.tiddlyspace.space import Space [as 别名]
# 或者: from tiddlywebplugins.tiddlyspace.space.Space import list_recipes [as 别名]
def test_list_recipes():
    space = Space('cat')
    assert sorted(space.list_recipes()) == ['cat_private', 'cat_public']
开发者ID:Alanchi,项目名称:tiddlyspace,代码行数:5,代码来源:test_space_object.py

示例4: _handle_core_request

# 需要导入模块: from tiddlywebplugins.tiddlyspace.space import Space [as 别名]
# 或者: from tiddlywebplugins.tiddlyspace.space.Space import list_recipes [as 别名]
    def _handle_core_request(self, environ, req_uri, start_response):
        """
        Override a core request, adding filters or sending 404s where
        necessary to limit the view of entities.

        filtering can be disabled with a custom HTTP header X-ControlView set
        to false
        """
        http_host, host_url = determine_host(environ)

        disable_ControlView = environ.get('HTTP_X_CONTROLVIEW') == 'false'
        if http_host != host_url and not disable_ControlView:
            space_name = determine_space(environ, http_host)
            if space_name == None:
                return None
            recipe_name = determine_space_recipe(environ, space_name)
            store = environ['tiddlyweb.store']
            try:
                recipe = store.get(Recipe(recipe_name))
            except NoRecipeError, exc:
                raise HTTP404('No recipe for space: %s', exc)

            space = Space(space_name)

            template = recipe_template(environ)
            bags = space.extra_bags()
            for bag, _ in recipe.get_recipe(template):
                bags.append(bag)
            bags.extend(ADMIN_BAGS)

            search_string = None
            if req_uri.startswith('/recipes') and req_uri.count('/') == 1:
                serialize_type, mime_type = get_serialize_type(environ)
                serializer = Serializer(serialize_type, environ)

                if recipe_name == space.private_recipe():
                    recipes = space.list_recipes()
                else:
                    recipes = [space.public_recipe()]

                def lister():
                    for recipe in recipes:
                        yield Recipe(recipe)

                return list_entities(environ, start_response, mime_type,
                    lister, serializer.list_recipes)

            elif req_uri.startswith('/bags') and req_uri.count('/') == 1:
                serialize_type, mime_type = get_serialize_type(environ)
                serializer = Serializer(serialize_type, environ)

                def lister():
                    for bag in bags:
                        yield Bag(bag)

                return list_entities(environ, start_response, mime_type,
                        lister, serializer.list_bags)

            elif req_uri.startswith('/search') and req_uri.count('/') == 1:
                search_string = ' OR '.join(['bag:%s' % bag
                    for bag in bags])
            else:
                entity_name = urllib.unquote(
                        req_uri.split('/')[2]).decode('utf-8')
                if '/recipes/' in req_uri:
                    valid_recipes = space.list_recipes()
                    if entity_name not in valid_recipes:
                        raise HTTP404('recipe %s not found due to ControlView'
                                % entity_name)
                else:
                    if entity_name not in bags:
                        raise HTTP404('bag %s not found due to ControlView'
                                % entity_name)

            if search_string:
                search_query = environ['tiddlyweb.query'].get('q', [''])[0]
                environ['tiddlyweb.query.original'] = search_query
                if search_query:
                    search_query = '%s AND (%s)' % (search_query,
                            search_string)
                    environ['tiddlyweb.query']['q'][0] = search_query
                else:
                    search_query = '(%s)' % search_string
                    environ['tiddlyweb.query']['q'] = [search_query]
开发者ID:Erls-Corporation,项目名称:tiddlyspace,代码行数:86,代码来源:controlview.py

示例5: _handle_core_request

# 需要导入模块: from tiddlywebplugins.tiddlyspace.space import Space [as 别名]
# 或者: from tiddlywebplugins.tiddlyspace.space.Space import list_recipes [as 别名]
    def _handle_core_request(self, environ, req_uri):
        """
        Override a core request, adding filters or sending 404s where
        necessary to limit the view of entities.

        filtering can be disabled with a custom HTTP header X-ControlView set
        to false
        """
        http_host, host_url = determine_host(environ)

        request_method = environ['REQUEST_METHOD']

        disable_ControlView = environ.get('HTTP_X_CONTROLVIEW') == 'false'
        if http_host != host_url and not disable_ControlView:
            space_name = determine_space(environ, http_host)
            if space_name == None:
                return
            recipe_name = determine_space_recipe(environ, space_name)
            store = environ['tiddlyweb.store']
            try:
                recipe = store.get(Recipe(recipe_name))
            except NoRecipeError, exc:
                raise HTTP404('No recipe for space: %s', exc)

            space = Space(space_name)

            template = recipe_template(environ)
            bags = space.extra_bags()
            for bag, _ in recipe.get_recipe(template):
                bags.append(bag)
            bags.extend(ADMIN_BAGS)

            filter_string = None
            if req_uri.startswith('/recipes') and req_uri.count('/') == 1:
                filter_string = 'oom=name:'
                if recipe_name == space.private_recipe():
                    filter_parts = space.list_recipes()
                else:
                    filter_parts = [space.public_recipe()]
                filter_string += ','.join(filter_parts)
            elif req_uri.startswith('/bags') and req_uri.count('/') == 1:
                filter_string = 'oom=name:'
                filter_parts = bags
                filter_string += ','.join(filter_parts)
            elif req_uri.startswith('/search') and req_uri.count('/') == 1:
                filter_string = 'oom=bag:'
                filter_parts = bags
                filter_string += ','.join(filter_parts)
            else:
                entity_name = req_uri.split('/')[2]
                if '/recipes/' in req_uri:
                    valid_recipes = space.list_recipes()
                    if entity_name not in valid_recipes:
                        raise HTTP404('recipe %s not found' % entity_name)
                else:
                    if entity_name not in bags:
                        raise HTTP404('bag %s not found' % entity_name)

            if filter_string:
                filters, _ = parse_for_filters(filter_string)
                for single_filter in filters:
                    environ['tiddlyweb.filters'].insert(0, single_filter)
开发者ID:EnoX1,项目名称:tiddlyspace,代码行数:64,代码来源:controlview.py


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