def test_IMutablePropertiesPlugin_set(self): """Set does nothing, but the sheet itselfs set immediatly""" user = self.pas.getUserById("uid0") from pas.plugins.ldap.sheet import LDAPUserPropertySheet sheet = LDAPUserPropertySheet(user, self.ldap) self.assertEqual(sheet.getProperty("mail"), "uid0@groupOfNames_10_10.com") sheet.setProperty(None, "mail", "*****@*****.**") self.assertEqual(sheet.getProperty("mail"), "*****@*****.**") sheet2 = LDAPUserPropertySheet(user, self.ldap) self.assertEqual(sheet2.getProperty("mail"), "*****@*****.**")
def test_IMutablePropertiesPlugin_pickle(self): user = self.pas.getUserById("uid0") from pas.plugins.ldap.sheet import LDAPUserPropertySheet sheet = LDAPUserPropertySheet(user, self.ldap) import pickle self.assertGreater(len(pickle.dumps(sheet)), 600)
def getPropertiesForUser(self, user_or_group, request=None): """User -> IMutablePropertySheet || {} o User will implement IPropertiedUser. ??? o Plugin may scribble on the user, if needed (but must still return a mapping, even if empty). o May assign properties based on values in the REQUEST object, if present """ ugid = user_or_group.getId() try: if self.enumerateUsers(id=ugid) or self.enumerateGroups(id=ugid): return LDAPUserPropertySheet(user_or_group, self) except KeyError: pass return {}
def getPropertiesForUser(self, user_or_group, request=None): """User -> IMutablePropertySheet || {} o User will implement IPropertiedUser. ??? o Plugin may scribble on the user, if needed (but must still return a mapping, even if empty). o May assign properties based on values in the REQUEST object, if present """ default = {} ugid = user_or_group.getId() if not isinstance(ugid, six.text_type): ugid = ugid.decode("utf-8") try: if (self.enumerateUsers(id=ugid, exact_match=True) or self.enumerateGroups(id=ugid, exact_match=True)): return LDAPUserPropertySheet(user_or_group, self) except KeyError: pass return default
def getPropertiesForUser(self, user_or_group, request=None): """User -> IMutablePropertySheet || {} o User will implement IPropertiedUser. ??? o Plugin may scribble on the user, if needed (but must still return a mapping, even if empty). o May assign properties based on values in the REQUEST object, if present """ default = {} if not self.is_plugin_active(pas_interfaces.IPropertiesPlugin): return default ugid = user_or_group.getId() users = self.users try: if ugid in self.getGroupIds() or users and users[ugid]: return LDAPUserPropertySheet(user_or_group, self) except KeyError: pass return default
def _getPropertiesForUser(self, user_or_group): return LDAPUserPropertySheet(user_or_group, self)