def getMemberById(self, id): ''' Returns the given member. ''' stack = inspect.stack() upstream_callers = '/'.join([a[3] for a in stack]) # If the requested callers is in the whitelist if upstream_callers in WHITELISTED_CALLERS: user = get_safe_member_by_id(id) if user is not None: user_towrap = PropertiedUser(id) # As we added the key 'id' into the local user catalog, we need to # get rid of the get_safe_member_by_id result to make # addPropertyShit (pun intended) happy user.pop('id', None) user_towrap.addPropertysheet('omega13', user) user = self.wrapUser(user_towrap) return user # If the user is not on the new catalog, then fallback anyway if api.env.debug_mode(): genweb_log.warning('') genweb_log.warning('Warning! Using getMemberById') genweb_log.warning('from: {}'.format(upstream_callers)) genweb_log.warning('') user = self._huntUser(id, self) if user is not None: user = self.wrapUser(user) return user
def getMemberById(self, id): ''' Returns the given member. ''' stack = inspect.stack() upstream_callers = '/'.join([a[3] for a in stack]) # If the requested callers is in the whitelist if upstream_callers in WHITELISTED_CALLERS: user = get_safe_member_by_id(id) if user is not None: user_towrap = PropertiedUser(id) user_towrap.addPropertysheet('omega13', user) user = self.wrapUser(user_towrap) return user # If the user is not on the new catalog, then fallback anyway if api.env.debug_mode(): # import ipdb;ipdb.set_trace() genweb_log.warning('') genweb_log.warning('Warning! Using getMemberById') genweb_log.warning('from: {}'.format(upstream_callers)) genweb_log.warning('') user = self._huntUser(id, self) if user is not None: user = self.wrapUser(user) return user
def getMemberById(self, id): ''' Returns the given member. ''' stack = inspect.stack() upstream_callers = '/'.join([a[3] for a in stack]) # If the requested callers is in the whitelist if upstream_callers in WHITELISTED_CALLERS: user = get_safe_member_by_id(id) if user is not None: user_towrap = PropertiedUser(id) # As we added the key 'id' into the local user catalog, we need to # get rid of the get_safe_member_by_id result to make # addPropertyShit (pun intended) happy user.pop('id', None) user_towrap.addPropertysheet('omega13', user) user = self.wrapUser(user_towrap) return user # If the user is not on the new catalog, then fallback anyway if api.env.debug_mode(): genweb_log.warning('') genweb_log.warning('Warning! Using getMemberById') genweb_log.warning('from: {}'.format(upstream_callers)) genweb_log.warning('') user = self._huntUser(id, self) if user is not None: user = self.wrapUser(user) return user
def test_groups_for_principal(self): from Products.PluggableAuthService.PropertiedUser import \ PropertiedUser uid = 'asd98' puser = PropertiedUser(uid) puser.isGroup = lambda: False groups = list(self._plugin.getGroupsForPrincipal(puser)) groups.sort() from Products.psuauthz.affiliation import affiliation_mapping expected_results = [affiliation_mapping[affiliation_data[uid]].id] self.failUnlessEqual(groups, expected_results)
def test_default_personalportlet_created_for_new_user(self): col = getUtility(IPortletManager, name='plone.rightcolumn') user_portlets = col[USER_CATEGORY] self.failIf('fakeuser' in user_portlets) # This would normally happen when a user is created notify(PrincipalCreated(PropertiedUser('fakeuser'))) # We would expect some portlets to have been created after the # event handler has finished processing self.failUnless('fakeuser' in user_portlets) self.assertEqual(len(user_portlets['fakeuser']), 1)
def test_default_dashboard_created_for_new_user(self): col = getUtility(IPortletManager, name='plone.dashboard1') user_portlets = col[USER_CATEGORY] self.assertFalse('fakeuser' in user_portlets) # This would normally happen when a user is created notify(PrincipalCreated(PropertiedUser('fakeuser'))) # We would expect some portlets to have been created after the # event handler has finished processing self.assertTrue('fakeuser' in user_portlets) self.assertTrue(len(user_portlets['fakeuser']) > 0)
def getGroupsForPrincipal(self, user, request=None): set = list(user.getGroups()) seen = [] parent = aq_parent(self) while set: test = set.pop(0) if test in seen: continue seen.append(test) new_groups = parent._getGroupsForPrincipal( PropertiedUser(test), ignore_plugins=(self.getId(), )) if new_groups: set.extend(new_groups) return tuple(seen)