Пример #1
0
 def update(self):
     service = getUtility(IMemberService)
     member = service.get_member(getSecurityManager().getUser().getId())
     if not IEditableMember.providedBy(member):
         self.fields['fullname'].mode = silvaforms.DISPLAY
         self.fields['email'].mode = silvaforms.DISPLAY
     self.user = UserDataManager(member, self.request)
Пример #2
0
 def get_cached_member_unexisting(self):
     service = queryUtility(IMemberService)
     member = service.get_cached_member('delta')
     members = self.root.Members
     self.assertTrue(verifyObject(IMember, member))
     self.assertFalse(IEditableMember.providedBy(member))
     self.assertEqual(member.userid(), 'unknown')
     self.assertEqual(member.fullname(), 'unknown')
     self.assertEqual(member.email(), None)
     self.assertEqual(members._getOb('delta', None), None)
Пример #3
0
 def get_cached_member_unexisting(self):
     service = queryUtility(IMemberService)
     member = service.get_cached_member('delta')
     members = self.root.Members
     self.assertTrue(verifyObject(IMember, member))
     self.assertFalse(IEditableMember.providedBy(member))
     self.assertEqual(member.userid(), 'unknown')
     self.assertEqual(member.fullname(), 'unknown')
     self.assertEqual(member.email(), None)
     self.assertEqual(members._getOb('delta', None), None)
Пример #4
0
    def get_cached_member(self):
        service = queryUtility(IMemberService)
        members = self.root.Members
        self.assertEqual(members._getOb('editor', None), None)
        member = service.get_cached_member('editor')
        self.assertTrue(verifyObject(IMember, member))
        self.assertFalse(IEditableMember.providedBy(member))
        self.assertEqual(member.userid(), 'editor')
        self.assertEqual(member.fullname(), 'editor')
        self.assertEqual(member.email(), None)

        # Changing the original member object doesn't affect the
        # cached one.
        original = members._getOb('editor')
        self.assertTrue(verifyObject(IMember, original))
        self.assertTrue(verifyObject(IEditableMember, original))
        self.assertNotEqual(original, member)
        original.set_fullname('Arthur de Pandragor')
        self.assertEqual(member.fullname(), None)
Пример #5
0
    def get_cached_member(self):
        service = queryUtility(IMemberService)
        members = self.root.Members
        self.assertEqual(members._getOb('editor', None), None)
        member = service.get_cached_member('editor')
        self.assertTrue(verifyObject(IMember, member))
        self.assertFalse(IEditableMember.providedBy(member))
        self.assertEqual(member.userid(), 'editor')
        self.assertEqual(member.fullname(), 'editor')
        self.assertEqual(member.email(), None)

        # Changing the original member object doesn't affect the
        # cached one.
        original = members._getOb('editor')
        self.assertTrue(verifyObject(IMember, original))
        self.assertTrue(verifyObject(IEditableMember, original))
        self.assertNotEqual(original, member)
        original.set_fullname('Arthur de Pandragor')
        self.assertEqual(member.fullname(), None)
Пример #6
0
 def set(self, key, value):
     if key in ('email', 'fullname'):
         if IEditableMember.providedBy(self.content):
             return getattr(self.content, 'set_' + key)(value)
     if key == 'language':
         return self.language.setPreferredLanguage(value)