本文整理汇总了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 ) )
示例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))
示例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 )
示例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)
示例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 ) )