Пример #1
0
def list_space_members(environ, start_response):
    """
    List the members of the named space. You must be a member
    to list the members.
    """
    store = environ['tiddlyweb.store']
    space_name = environ['wsgiorg.routing_args'][1]['space_name']
    current_user = environ['tiddlyweb.usersign']
    try:
        space = Space(space_name)
        private_space_bag = store.get(Bag(space.private_bag()))
        private_space_bag.policy.allows(current_user, 'manage')
        members = [member for member in private_space_bag.policy.manage if
                not member.startswith('R:')]
    except (ValueError, NoBagError):
        raise HTTP404('No space for %s' % space_name)
    start_response('200 OK', [
        ('Cache-Control', 'no-cache'),
        ('Content-Type', 'application/json; charset=UTF-8')])
    return simplejson.dumps(members)
Пример #2
0
def list_space_members(environ, start_response):
    """
    List the members of the named space. You must be a member
    to list the members.
    """
    store = environ['tiddlyweb.store']
    space_name = environ['wsgiorg.routing_args'][1]['space_name']
    current_user = environ['tiddlyweb.usersign']
    try:
        space = Space(space_name)
        private_space_bag = store.get(Bag(space.private_bag()))
        private_space_bag.policy.allows(current_user, 'manage')
        members = [
            member for member in private_space_bag.policy.manage
            if not member.startswith('R:')
        ]
    except (ValueError, NoBagError):
        raise HTTP404('No space for %s' % space_name)
    start_response('200 OK',
                   [('Cache-Control', 'no-cache'),
                    ('Content-Type', 'application/json; charset=UTF-8')])
    return simplejson.dumps(members)
Пример #3
0
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',
}

#  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', ''),
Пример #4
0
    ('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': [
            ('system', ''),
Пример #5
0
def test_private_bag():
    space = Space('cat')
    assert space.private_bag() == 'cat_private'
Пример #6
0
def test_private_bag():
    space = Space('cat')
    assert space.private_bag() == 'cat_private'