Пример #1
0
 def add_groups(self, groups):
     """Add group names to set of groups.
     Member groups will be updated at validation.
     The set of members are the children of the node.
     The set of groups are the parents of the node.
     """
     self.groups.update(set(sanitise_name(group) for group in groups))
Пример #2
0
 def remove_groups(self, groups):
     """Find each group and remove from the set. Unknown groups will be
     ignored. Could raise an Exception if necessary.
     Intentionally there is no remove_member, to make it clear which way
     the adding and removing is done.
     """
     self.groups.difference_update(set(sanitise_name(group)
                                       for group in groups))
Пример #3
0
 def test_sanitise_name(self):
     self.assertEqual(sanitise_name('one'), 'one')
     self.assertEqual(sanitise_name(' two two '), 'two_two')
     self.assertEqual(sanitise_name('thREE   three'), 'three_three')
Пример #4
0
 def set_name_and_caption(self):
     """Use requested name for the caption, but sanitise name.
     """
     self.name = self.name or 'name-missing'
     self.caption = init_caps(self.name)
     self.name = sanitise_name(self.name)