Changeset 6673 for main/waeup.sirp/trunk/src
- Timestamp:
- 3 Sep 2011, 23:38:21 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/authentication.py
r6672 r6673 26 26 for name, util in auth_plugin_utilities: 27 27 util.register(pau) 28 29 def get_principal_role_manager(): 30 """Get a role manager for principals. 31 32 If we are currently 'in a site', return the role manager for the 33 portal or the global rolemanager else. 34 """ 35 portal = grok.getSite() 36 if portal is not None: 37 return IPrincipalRoleManager(portal) 38 return principalRoleManager 28 39 29 40 class WAeUPSessionCredentialsPlugin(grok.GlobalUtility, … … 74 85 75 86 def getRoles(self): 76 prm = self._getPrincipalRoleManager()87 prm = get_principal_role_manager() 77 88 roles = [x[0] for x in prm.getRolesForPrincipal(self.name) 78 89 if x[0].startswith('waeup.')] … … 80 91 81 92 def setRoles(self, roles): 82 prm = self._getPrincipalRoleManager()93 prm = get_principal_role_manager() 83 94 84 95 old_roles = self.getRoles() … … 107 118 self._p_changed = True 108 119 return 109 110 def _getPrincipalRoleManager(self):111 portal = grok.getSite()112 if portal is not None:113 return IPrincipalRoleManager(portal)114 return principalRoleManager115 120 116 121 class UserAuthenticatorPlugin(grok.GlobalUtility): -
main/waeup.sirp/trunk/src/waeup/sirp/tests/test_authentication.py
r6617 r6673 4 4 from zope.interface.verify import verifyClass, verifyObject 5 5 from zope.pluggableauth.interfaces import IAuthenticatorPlugin 6 from zope.securitypolicy.interfaces import IPrincipalRoleManager 6 7 from waeup.sirp.testing import FunctionalTestCase, FunctionalLayer 7 8 from waeup.sirp.authentication import ( 8 UserAuthenticatorPlugin, Account, PrincipalInfo )9 UserAuthenticatorPlugin, Account, PrincipalInfo, get_principal_role_manager) 9 10 10 11 class FakeSite(grok.Site, grok.Container): … … 57 58 self.assertTrue(result2 is None) 58 59 return 60 61 def test_get_principal_role_manager(self): 62 # make sure we get different role managers for different situations 63 prm1 = get_principal_role_manager() 64 clearSite(None) 65 prm2 = get_principal_role_manager() 66 self.assertTrue(IPrincipalRoleManager.providedBy(prm1)) 67 self.assertTrue(IPrincipalRoleManager.providedBy(prm2)) 68 self.assertTrue(prm1._context is self.site) 69 self.assertTrue(hasattr(prm2, '_context') is False) 70 return
Note: See TracChangeset for help on using the changeset viewer.