Exemplo n.º 1
0
    def test_ACLRegistry(self):
        class SomeModel(object):
            pass

        acl = [('Allow', 'role:viewer', ['view'])]
        acl_registry.register(acl, SomeModel)

        acl = [('Allow', 'role:viewer', ['edit'])]
        acl_registry.register(acl, node_info_name='some_model')

        acl = [('Allow', 'role:viewer', ['delete'])]
        acl_registry.register(acl, SomeModel, 'some_model')

        self.assertEqual(
            acl_registry.lookup(None, None, [('Allow', 'role:viewer', ['add'])]),
            [('Allow', 'role:viewer', ['add'])]
        )
        self.assertEqual(
            acl_registry.lookup(SomeModel),
            [('Allow', 'role:viewer', ['view'])]
        )
        self.assertEqual(
            acl_registry.lookup(node_info_name='some_model'),
            [('Allow', 'role:viewer', ['edit'])]
        )
        self.assertEqual(
            acl_registry.lookup(SomeModel, 'some_model'),
            [('Allow', 'role:viewer', ['delete'])]
        )
Exemplo n.º 2
0
def initialize_ugm(config, global_config, local_config):
    """Initialize UGM.
    """
    # custom UGM styles
    cfg.merged.css.protected.append((static_resources, 'styles.css'))

    # custom UGM javascript
    cfg.merged.js.protected.append((static_resources, 'ugm.js'))

    # UGM settings
    register_config('ugm_general', GeneralSettings)
    register_config('ugm_server', ServerSettings)
    register_config('ugm_users', UsersSettings)
    register_config('ugm_groups', GroupsSettings)
    register_config('ugm_roles', RolesSettings)
    register_config('ugm_localmanager', LocalManagerSettings)

    # Users container
    register_entry('users', users_factory)

    # Groups container
    register_entry('groups', groups_factory)

    # register default acl's
    # XXX: define permissions referring users, user, groups respective group only
    acl_registry.register(ugm_user_acl, User, 'user')
    acl_registry.register(ugm_default_acl, Users, 'users')
    acl_registry.register(ugm_default_acl, Group, 'group')
    acl_registry.register(ugm_default_acl, Groups, 'groups')

    # localmanager config file location
    lm_config = local_config.get('ugm.localmanager_config', '')
    os.environ['LOCAL_MANAGER_CFG_FILE'] = lm_config

    # add translation
    config.add_translation_dirs('cone.ugm:locale/')

    # static resources
    config.add_view(static_resources, name='cone.ugm.static')

    # scan browser package
    config.scan('cone.ugm.browser')
Exemplo n.º 3
0
def initialize_ugm(config, global_config, settings):
    """Initialize UGM.
    """
    # custom UGM styles
    cfg.merged.css.protected.append((browser.static_resources, 'styles.css'))

    # custom UGM javascript
    cfg.merged.js.protected.append((browser.static_resources, 'ugm.js'))

    # config file locations
    ugm_cfg.ugm_settings = settings.get('ugm.config', '')
    ugm_cfg.lm_settings = settings.get('ugm.localmanager_config', '')

    # UGM settings
    register_config('ugm_general', GeneralSettings)
    register_config('ugm_localmanager', LocalManagerSettings)

    # Users container
    register_entry('users', Users)

    # Groups container
    register_entry('groups', Groups)

    # register default acl's
    # XXX: define permissions referring users, user, groups respective group only
    acl_registry.register(ugm_user_acl, User, 'user')
    acl_registry.register(ugm_default_acl, Users, 'users')
    acl_registry.register(ugm_default_acl, Group, 'group')
    acl_registry.register(ugm_default_acl, Groups, 'groups')

    # add translation
    config.add_translation_dirs('cone.ugm:locale/')

    # static resources
    config.add_view(browser.static_resources, name='cone.ugm.static')

    # scan browser package
    config.scan(browser)
Exemplo n.º 4
0
cfg.yafowil.js_skip.add('yafowil.widget.location.dependencies')
cfg.yafowil.css_skip.add('yafowil.widget.location.dependencies')

# plugin entry nodes
cone.app.register_plugin('about', model.About)
cone.app.register_plugin('locations', model.Locations)
cone.app.register_plugin('facilities', model.Facilities)
cone.app.register_plugin('occasions', model.Occasions)
cone.app.register_plugin('attachments', model.Attachments)

# plugin settings
cone.app.register_plugin_config('chronotope', model.Settings)

# register ACL's for nodes
if not os.environ.get('TESTRUN_MARKER'):
    acl_registry.register(chronotope_root_acl, AppRoot)

acl_registry.register(chronotope_container_acl, model.Locations, 'locations')
acl_registry.register(chronotope_container_acl, model.Facilities, 'facilities')
acl_registry.register(chronotope_container_acl, model.Occasions, 'occasions')
acl_registry.register(
    chronotope_container_acl, model.Attachments, 'attachments')


# application startup initialization
def initialize_chronotope(config, global_config, local_config):
    # chronotope layout adapter
    config.registry.registerAdapter(ChronotopeLayout)

    # add translation
    config.add_translation_dirs('chronotope:locales/')
Exemplo n.º 5
0
  + user_management_permissions \
  + group_management_permissions
ugm_default_acl = [
    (Allow, 'role:editor', ['view', 'manage_membership']),
    (Allow, 'role:admin', admin_permissions),
    (Allow, 'role:manager', admin_permissions + ['manage']),
    (Allow, Everyone, ['login']),
    (Deny, Everyone, ALL_PERMISSIONS),
]
ugm_user_acl = [
    (Allow, 'system.Authenticated', ['view_portrait']),
] + ugm_default_acl

# register default acl's
# XXX: define permissions referring users, user, groups respective group only,
acl_registry.register(ugm_user_acl, User, 'user')
acl_registry.register(ugm_default_acl, Users, 'users')
acl_registry.register(ugm_default_acl, Group, 'group')
acl_registry.register(ugm_default_acl, Groups, 'groups')


# application startup hooks
def initialize_ugm(config, global_config, local_config):
    """Initialize UGM.
    """
    # add translation
    config.add_translation_dirs('cone.ugm:locale/')

    # static resources
    config.add_view('cone.ugm.browser.static_resources',
                    name='cone.ugm.static')