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


Python Space.public_recipe方法代码示例

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


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

示例1: _make_space

# 需要导入模块: from tiddlywebplugins.tiddlyspace.space import Space [as 别名]
# 或者: from tiddlywebplugins.tiddlyspace.space.Space import public_recipe [as 别名]
def _make_space(environ, space_name):
    """
    The details of creating the bags and recipes that make up a space.
    """
    store = environ['tiddlyweb.store']
    member = environ['tiddlyweb.usersign']['name']

    # XXX stub out the clumsy way for now
    # can make this much more declarative

    space = Space(space_name)

    for bag_name in space.list_bags():
        bag = Bag(bag_name)
        bag.policy = _make_policy(member)
        if Space.bag_is_public(bag_name):
            bag.policy.read = []
        store.put(bag)

    public_recipe = Recipe(space.public_recipe())
    public_recipe.set_recipe(space.public_recipe_list())
    private_recipe = Recipe(space.private_recipe())
    private_recipe.set_recipe(space.private_recipe_list())
    private_recipe.policy = _make_policy(member)
    public_recipe.policy = _make_policy(member)
    public_recipe.policy.read = []
    store.put(public_recipe)
    store.put(private_recipe)
开发者ID:carnotip,项目名称:tiddlyspace,代码行数:30,代码来源:spaces.py

示例2: make_space

# 需要导入模块: from tiddlywebplugins.tiddlyspace.space import Space [as 别名]
# 或者: from tiddlywebplugins.tiddlyspace.space.Space import public_recipe [as 别名]
def make_space(space_name, store, member):
    """
    The details of creating the bags and recipes that make up a space.
    """
    space = Space(space_name)

    for bag_name in space.list_bags():
        bag = Bag(bag_name)
        bag.policy = _make_policy(member)
        if Space.bag_is_public(bag_name):
            bag.policy.read = []
        store.put(bag)

    info_tiddler = Tiddler('SiteInfo', space.public_bag())
    info_tiddler.text = 'Space %s' % space_name
    store.put(info_tiddler)

    public_recipe = Recipe(space.public_recipe())
    public_recipe.set_recipe(space.public_recipe_list())
    private_recipe = Recipe(space.private_recipe())
    private_recipe.set_recipe(space.private_recipe_list())
    private_recipe.policy = _make_policy(member)
    public_recipe.policy = _make_policy(member)
    public_recipe.policy.read = []
    store.put(public_recipe)
    store.put(private_recipe)
开发者ID:ramanathanr,项目名称:tiddlyspace,代码行数:28,代码来源:spaces.py

示例3: determine_space_recipe

# 需要导入模块: from tiddlywebplugins.tiddlyspace.space import Space [as 别名]
# 或者: from tiddlywebplugins.tiddlyspace.space.Space import public_recipe [as 别名]
def determine_space_recipe(environ, space_name):
    """
    Given a space name, check if the current user is a member of that
    named space. If so, use the private recipe.
    """
    store = environ['tiddlyweb.store']
    usersign = environ['tiddlyweb.usersign']
    try:
        space = Space(space_name)
        recipe = Recipe(space.public_recipe())
        recipe = store.get(recipe)
    except (ValueError, StoreError), exc:
        raise HTTP404('Space for %s does not exist: %s' % (space_name, exc))
开发者ID:Erls-Corporation,项目名称:tiddlyspace,代码行数:15,代码来源:web.py

示例4: confirm_space

# 需要导入模块: from tiddlywebplugins.tiddlyspace.space import Space [as 别名]
# 或者: from tiddlywebplugins.tiddlyspace.space.Space import public_recipe [as 别名]
def confirm_space(environ, start_response):
    """
    Confirm a spaces exists. If it does, raise 204. If
    not, raise 404.
    """
    store = environ['tiddlyweb.store']
    space_name = environ['wsgiorg.routing_args'][1]['space_name']
    try:
        space = Space(space_name)
        store.get(Recipe(space.public_recipe()))
        store.get(Recipe(space.private_recipe()))
    except NoRecipeError:
        raise HTTP404('%s does not exist' % space_name)
    start_response('204 No Content', [])
    return ['']
开发者ID:FND,项目名称:tiddlyspace,代码行数:17,代码来源:spaces.py

示例5: confirm_space

# 需要导入模块: from tiddlywebplugins.tiddlyspace.space import Space [as 别名]
# 或者: from tiddlywebplugins.tiddlyspace.space.Space import public_recipe [as 别名]
def confirm_space(environ, start_response):
    """
    Confirm a spaces exists. If it does, raise 204. If
    not, raise 404.
    """
    store = environ['tiddlyweb.store']
    space_name = get_route_value(environ, 'space_name')
    try:
        space = Space(space_name)
        store.get(Recipe(space.public_recipe()))
        store.get(Recipe(space.private_recipe()))
    except (NoRecipeError, ValueError):
        raise HTTP404('%s does not exist' % space_name)
    start_response('204 No Content', [])
    return ['']
开发者ID:Alanchi,项目名称:tiddlyspace,代码行数:17,代码来源:spaces.py

示例6: make_space

# 需要导入模块: from tiddlywebplugins.tiddlyspace.space import Space [as 别名]
# 或者: from tiddlywebplugins.tiddlyspace.space.Space import public_recipe [as 别名]
def make_space(space_name, store, member):
    """
    The details of creating the bags and recipes that make up a space.
    """
    space = Space(space_name)

    for bag_name in space.list_bags():
        bag = Bag(bag_name)
        bag.policy = _make_policy(member)
        if Space.bag_is_public(bag_name):
            bag.policy.read = []
        store.put(bag)

    info_tiddler = Tiddler('SiteInfo', space.public_bag())
    info_tiddler.text = 'Space %s' % space_name
    info_tiddler.modifier = store.environ.get('tiddlyweb.usersign',
            {}).get('name', 'GUEST')
    store.put(info_tiddler)

    # Duplicate GettingStarted into public bag.
    getting_started_tiddler = Tiddler(GETTING_STARTED_TIDDLER['title'],
            GETTING_STARTED_TIDDLER['bag'])
    try:
        getting_started_tiddler = store.get(getting_started_tiddler)
        getting_started_tiddler.bag = space.public_bag()
        store.put(getting_started_tiddler)
    except StoreError:
        pass

    public_recipe = Recipe(space.public_recipe())
    public_recipe.set_recipe(space.public_recipe_list())
    private_recipe = Recipe(space.private_recipe())
    private_recipe.set_recipe(space.private_recipe_list())
    private_recipe.policy = _make_policy(member)
    public_recipe.policy = _make_policy(member)
    public_recipe.policy.read = []
    store.put(public_recipe)
    store.put(private_recipe)
开发者ID:Alanchi,项目名称:tiddlyspace,代码行数:40,代码来源:spaces.py

示例7: Space

# 需要导入模块: from tiddlywebplugins.tiddlyspace.space import Space [as 别名]
# 或者: from tiddlywebplugins.tiddlyspace.space.Space import public_recipe [as 别名]
frontpage_policy = store_structure['bags']['frontpage_public']['policy']
spaces = {
    'system-theme': 'TiddlySpace default theme',
    'system-info': 'TiddlySpace default information tiddlers',
    'system-plugins': 'TiddlySpace system plugins',
    'system-images': 'TiddlySpace default images and icons',
    'system-applications': 'TiddlySpace default applications'
}

#  setup system space public bags and recipes
for space_name, description in spaces.items():
    space = Space(space_name)
    public_bag_name = space.public_bag()
    private_bag_name = space.private_bag()
    public_recipe_name = space.public_recipe()
    private_recipe_name = space.private_recipe()

    store_structure['bags'][public_bag_name] = {
        'desc': description,
        'policy': frontpage_policy,
    }
    store_structure['bags'][private_bag_name] = deepcopy(
        store_structure['bags'][public_bag_name])
    store_structure['bags'][private_bag_name]['policy']['read'] = ['R:ADMIN']

    store_structure['recipes'][public_recipe_name] = {
        'desc': description,
        'recipe': [
            ('system', ''),
            ('tiddlyspace', ''),
开发者ID:Erls-Corporation,项目名称:tiddlyspace,代码行数:32,代码来源:instance.py

示例8: test_public_recipe

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

示例9: _handle_core_request

# 需要导入模块: from tiddlywebplugins.tiddlyspace.space import Space [as 别名]
# 或者: from tiddlywebplugins.tiddlyspace.space.Space import public_recipe [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

示例10: _handle_core_request

# 需要导入模块: from tiddlywebplugins.tiddlyspace.space import Space [as 别名]
# 或者: from tiddlywebplugins.tiddlyspace.space.Space import public_recipe [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.public_recipe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。