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


Python rolemap.importRolemap函数代码示例

本文整理汇总了Python中Products.GenericSetup.rolemap.importRolemap函数的典型用法代码示例。如果您正苦于以下问题:Python importRolemap函数的具体用法?Python importRolemap怎么用?Python importRolemap使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_unacquired_permission_skip_purge

    def test_unacquired_permission_skip_purge( self ):

        ACI = 'Access contents information'
        VIEW = 'View'

        self.app.site = Folder(id='site')
        site = self.app.site
        site.manage_permission( VIEW, () )

        existing_allowed = [ x[ 'name' ]
                                for x in site.rolesOfPermission( ACI )
                                if x[ 'selected' ] ]

        self.assertEqual( existing_allowed, [ 'Manager' ] )

        self.failUnless( site.acquiredRolesAreUsedBy( ACI ) )
        self.failIf( site.acquiredRolesAreUsedBy( VIEW ) )

        context = DummyImportContext( site, False )
        context._files[ 'rolemap.xml' ] = _UNACQUIRED_EXPORT

        from Products.GenericSetup.rolemap import importRolemap
        importRolemap( context )

        new_allowed = [ x[ 'name' ]
                           for x in site.rolesOfPermission( ACI )
                           if x[ 'selected' ] ]

        self.assertEqual( new_allowed, [ 'Manager', 'Owner' ] )

        self.failIf( site.acquiredRolesAreUsedBy( ACI ) )
        self.failIf( site.acquiredRolesAreUsedBy( VIEW ) )
开发者ID:dtgit,项目名称:dtedu,代码行数:32,代码来源:test_rolemap.py

示例2: test_acquired_permission_explicit_purge

    def test_acquired_permission_explicit_purge(self):

        ACI = 'Access contents information'
        VIEW = 'View'

        self.app.site = Folder(id='site')
        site = self.app.site
        site.manage_permission(ACI, ())
        site.manage_permission(VIEW, ())

        existing_allowed = [x['name']
                            for x in site.rolesOfPermission(ACI)
                            if x['selected']]

        self.assertEqual(existing_allowed, [])

        self.assertFalse(site.acquiredRolesAreUsedBy(ACI))
        self.assertFalse(site.acquiredRolesAreUsedBy(VIEW))

        context = DummyImportContext(site, True)
        context._files['rolemap.xml'] = _ACQUIRED_EXPORT

        from Products.GenericSetup.rolemap import importRolemap
        importRolemap(context)

        new_allowed = [x['name']
                       for x in site.rolesOfPermission(ACI)
                       if x['selected']]

        self.assertEqual(new_allowed, ['Manager', 'Owner'])

        # ACI is overwritten by XML, but VIEW was purged
        self.assertTrue(site.acquiredRolesAreUsedBy(ACI))
        self.assertTrue(site.acquiredRolesAreUsedBy(VIEW))
开发者ID:zopefoundation,项目名称:Products.GenericSetup,代码行数:34,代码来源:test_rolemap.py

示例3: test_empty_skip_purge

    def test_empty_skip_purge( self ):

        self.app.site = Folder(id='site')
        site = self.app.site
        original_roles = list( getattr( site, '__ac_roles__', [] ) )[:]
        modified_roles = original_roles[:]
        modified_roles.append( 'ZZZ' )
        site.__ac_roles__ = modified_roles

        context = DummyImportContext( site, False )
        context._files[ 'rolemap.xml' ] = _EMPTY_EXPORT

        from Products.GenericSetup.rolemap import importRolemap
        importRolemap( context )

        new_roles = list( getattr( site, '__ac_roles__', [] ) )[:]

        modified_roles.sort()
        new_roles.sort()

        self.assertEqual( modified_roles, new_roles )
开发者ID:dtgit,项目名称:dtedu,代码行数:21,代码来源:test_rolemap.py

示例4: test_existing_roles_missing_xml_doesnt_purge

    def test_existing_roles_missing_xml_doesnt_purge(self):
        # LP # 279294
        ACI = 'Access contents information'
        VIEW = 'View'

        self.app.site = Folder(id='site')
        site = self.app.site # wrap
        original_roles = list(getattr(site, '__ac_roles__', []))[:]
        modified_roles = original_roles[:]
        modified_roles.append('ZZZ')

        site.__ac_roles__ = modified_roles
        site.manage_permission(VIEW, ())
        site.manage_permission(ACI, ('Manager', 'ZZZ'))

        existing_allowed = [x['name'] for x in site.rolesOfPermission(ACI)
                                if x['selected']]

        self.assertEqual(existing_allowed, ['Manager', 'ZZZ'])

        context = DummyImportContext(site, True)
        #context._files[ 'rolemap.xml' ] = _EMPTY_EXPORT # no file!

        from Products.GenericSetup.rolemap import importRolemap
        importRolemap(context)

        new_roles = list(getattr(site, '__ac_roles__', []))[:]

        modified_roles.sort()
        new_roles.sort()

        self.assertEqual(modified_roles, new_roles)

        new_allowed = [x['name'] for x in site.rolesOfPermission(ACI)
                                if x['selected']]

        self.assertEqual(new_allowed, existing_allowed)
开发者ID:MatthewWilkes,项目名称:Products.GenericSetup,代码行数:37,代码来源:test_rolemap.py

示例5: test_unacquired_permission_added_role_skip_purge_encode_ascii

    def test_unacquired_permission_added_role_skip_purge_encode_ascii( self ):

        ACI = 'Access contents information'
        VIEW = 'View'

        self.root.site = Folder( id='site' )
        site = self.root.site
        site.manage_permission( VIEW, () )

        existing_allowed = [ x[ 'name' ]
                                for x in site.rolesOfPermission( ACI )
                                if x[ 'selected' ] ]

        self.assertEqual( existing_allowed, [ 'Manager' ] )

        self.failUnless( site.acquiredRolesAreUsedBy( ACI ) )
        self.failIf( site.acquiredRolesAreUsedBy( VIEW ) )

        self.failIf( site._has_user_defined_role( 'ZZZ' ) )

        context = DummyImportContext( site, False, encoding='ascii' )
        context._files[ 'rolemap.xml' ] = _COMBINED_EXPORT

        from Products.GenericSetup.rolemap import importRolemap
        importRolemap( context )

        self.failUnless( site._has_user_defined_role( 'ZZZ' ) )

        new_allowed = [ x[ 'name' ]
                           for x in site.rolesOfPermission( ACI )
                           if x[ 'selected' ] ]

        self.assertEqual( new_allowed, [ 'Manager', 'Owner', 'ZZZ' ] )

        self.failIf( site.acquiredRolesAreUsedBy( ACI ) )
        self.failIf( site.acquiredRolesAreUsedBy( VIEW ) )
开发者ID:goschtl,项目名称:zope,代码行数:36,代码来源:test_rolemap.py


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