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


Python Space.public_bag方法代码示例

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


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

示例1: make_space

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

示例2: update_space_settings

# 需要导入模块: from tiddlywebplugins.tiddlyspace.space import Space [as 别名]
# 或者: from tiddlywebplugins.tiddlyspace.space.Space import public_bag [as 别名]
def update_space_settings(environ, name):
    """
    Read a tiddler named by SPACE_SERVER_SETTINGS in the current
    space's public bag. Parse each line as a key:value pair which
    is then injected tiddlyweb.query. The goal here is to allow
    a space member to force incoming requests to use specific
    settings, such as alpha or externalized.
    """
    store = environ['tiddlyweb.store']
    space = Space(name)
    bag_name = space.public_bag()
    tiddler = Tiddler(SPACE_SERVER_SETTINGS, bag_name)
    data_text = ''
    try:
        tiddler = store.get(tiddler)
        data_text = tiddler.text
    except StoreError:
        pass

    for line in data_text.split('\n'):
        try:
            key, value = line.split(':', 1)
            key = key.rstrip().lstrip()
            value = value.rstrip().lstrip()
            try:
                environ['tiddlyweb.query'][key].append(value)
            except KeyError:
                environ['tiddlyweb.query'][key] = [value]
        except ValueError:
            pass
开发者ID:blaine,项目名称:tiddlyspace,代码行数:32,代码来源:handler.py

示例3: _validate_subscription

# 需要导入模块: from tiddlywebplugins.tiddlyspace.space import Space [as 别名]
# 或者: from tiddlywebplugins.tiddlyspace.space.Space import public_bag [as 别名]
def _validate_subscription(environ, name, recipe):
    """
    Determine if this space can be subscribed to.

    We know that the space exists, what we want to determine here is if
    it has been blacklisted or already been subscribed.
    """
    space = Space(name)
    if name in environ['tiddlyweb.config'].get('blacklisted_spaces', []):
        raise HTTP409('Subscription not allowed to space: %s' % name)
    elif [space.public_bag(), ''] in recipe:
        raise HTTP409('Space already subscribed: %s' % name)
    return space
开发者ID:FND,项目名称:tiddlyspace,代码行数:15,代码来源:spaces.py

示例4: make_space

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

示例5: update_space_settings

# 需要导入模块: from tiddlywebplugins.tiddlyspace.space import Space [as 别名]
# 或者: from tiddlywebplugins.tiddlyspace.space.Space import public_bag [as 别名]
def update_space_settings(environ, name):
    """
    Read a tiddler named by SPACE_SERVER_SETTINGS in the current
    space's public bag. Parse each line as a key:value pair which
    is then injected tiddlyweb.query. The goal here is to allow
    a space member to force incoming requests to use specific
    settings, such as alpha or externalized.
    """
    store = environ['tiddlyweb.store']
    space = Space(name)
    bag_name = space.public_bag()
    tiddler = Tiddler(SPACE_SERVER_SETTINGS, bag_name)
    data_text = ''
    try:
        tiddler = store.get(tiddler)
        data_text = tiddler.text
    except StoreError:
        return _figure_default_index(environ, bag_name, space), False

    query_strings = []
    index = ''
    lazy = False
    for line in data_text.split('\n'):
        try:
            key, value = line.split(':', 1)
            key = key.rstrip().lstrip()
            value = value.rstrip().lstrip()
            if key == 'index':
                index = value
            elif key == 'lazy':
                if value.lower() == 'true':
                    lazy = True
            else:
                query_strings.append('%s=%s' % (key, value))
        except ValueError:
            pass

    index = _figure_default_index(environ, bag_name, space, index)

    query_string = ';'.join(query_strings)

    filters, leftovers = parse_for_filters(query_string, environ)
    environ['tiddlyweb.filters'].extend(filters)
    query_data = parse_qs(leftovers, keep_blank_values=True)
    environ['tiddlyweb.query'].update(dict(
        [(key, [value for value in values])
            for key, values in query_data.items()]))

    return index, lazy
开发者ID:Erls-Corporation,项目名称:tiddlyspace,代码行数:51,代码来源:handler.py

示例6: _do_unsubscriptions

# 需要导入模块: from tiddlywebplugins.tiddlyspace.space import Space [as 别名]
# 或者: from tiddlywebplugins.tiddlyspace.space.Space import public_bag [as 别名]
def _do_unsubscriptions(space_name, unsubscriptions, public_recipe_list,
        private_recipe_list, store):
    """
    Remove unsubscriptions from the space represented by
    public_recipe_list and private_recipe_list.
    """
    for space in unsubscriptions:
        if space == space_name:
            raise HTTP409('Attempt to unsubscribe self')
        try:
            unsubscribed_space = Space(space)
            bag = unsubscribed_space.public_bag()
            public_recipe_list.remove([bag, ""])
            private_recipe_list.remove([bag, ""])
        except ValueError, exc:
            raise HTTP409('Invalid content for unsubscription: %s' % exc)
开发者ID:FND,项目名称:tiddlyspace,代码行数:18,代码来源:spaces.py

示例7: update_space_settings

# 需要导入模块: from tiddlywebplugins.tiddlyspace.space import Space [as 别名]
# 或者: from tiddlywebplugins.tiddlyspace.space.Space import public_bag [as 别名]
def update_space_settings(environ, name):
    """
    Read a tiddler named by SPACE_SERVER_SETTINGS in the current
    space's public bag. Parse each line as a key:value pair which
    is then injected tiddlyweb.query. The goal here is to allow
    a space member to force incoming requests to use specific
    settings, such as alpha or externalized.
    """
    store = environ['tiddlyweb.store']
    # double assign to avoid later updates to the defaults
    environ['tiddlyweb.space_settings'] = {}
    environ['tiddlyweb.space_settings'].update(DEFAULT_SERVER_SETTINGS)
    try:
        space = Space(name)
    except ValueError:
        return
    bag_name = space.public_bag()
    tiddler = Tiddler(SPACE_SERVER_SETTINGS, bag_name)
    data_text = ''
    try:
        tiddler = store.get(tiddler)
        data_text = tiddler.text
    except StoreError:
        data_text = ''

    query_strings = []
    for line in data_text.split('\n'):
        try:
            key, value = line.split(':', 1)
            key = key.strip()
            value = value.strip()
            if key in SERVER_SETTINGS_KEYS:
                environ['tiddlyweb.space_settings'][key] = value
            else:
                query_strings.append('%s=%s' % (key, value))
        except ValueError:
            pass

    # XXX: Disable the default new user app switcher temporarily
    # TODO: Turn this back on when the app switcher is more complete
    #_figure_default_index(environ, bag_name, space)

    environ['tiddlyweb.space_settings'][
            'extra_query'] = ';'.join(query_strings)
开发者ID:moveek,项目名称:tiddlyspace,代码行数:46,代码来源:serversettings.py

示例8: Space

# 需要导入模块: from tiddlywebplugins.tiddlyspace.space import Space [as 别名]
# 或者: from tiddlywebplugins.tiddlyspace.space.Space import public_bag [as 别名]
store_structure['recipes']['frontpage_private']['recipe'].append(
    ('frontpage_private', ''))

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': [
开发者ID:Erls-Corporation,项目名称:tiddlyspace,代码行数:33,代码来源:instance.py

示例9: test_public_bag

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


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