src/pyams_security/plugin/group.py
changeset 15 cb45428a26a1
parent 5 181b8ff133b7
child 42 07229ac2497b
equal deleted inserted replaced
14:999c46679f3e 15:cb45428a26a1
    12 
    12 
    13 __docformat__ = 'restructuredtext'
    13 __docformat__ = 'restructuredtext'
    14 
    14 
    15 
    15 
    16 # import standard library
    16 # import standard library
       
    17 import logging
       
    18 logger = logging.getLogger('PyAMS(security)')
    17 
    19 
    18 # import interfaces
    20 # import interfaces
    19 from pyams_security.interfaces import IGroupsFolderPlugin, ILocalGroup, IPrincipalsAddedToGroupEvent, \
    21 from pyams_security.interfaces import IGroupsFolderPlugin, ILocalGroup, IPrincipalsAddedToGroupEvent, \
    20     IPrincipalsRemovedFromGroupEvent, PrincipalsAddedToGroupEvent, PrincipalsRemovedFromGroupEvent
    22     IPrincipalsRemovedFromGroupEvent, PrincipalsAddedToGroupEvent, PrincipalsRemovedFromGroupEvent
    21 from zope.lifecycleevent.interfaces import IObjectAddedEvent
    23 from zope.lifecycleevent.interfaces import IObjectAddedEvent
    52         removed = self._principals - value
    54         removed = self._principals - value
    53         if added or removed:
    55         if added or removed:
    54             self._principals = value
    56             self._principals = value
    55             registry = check_request().registry
    57             registry = check_request().registry
    56             if added:
    58             if added:
    57                 print(">> added =", added)
    59                 logger.debug("Added principals {0} to group {1} ({2})".format(str(added), self.group_id,
       
    60                                                                               self.title))
    58                 registry.notify(PrincipalsAddedToGroupEvent(self, added))
    61                 registry.notify(PrincipalsAddedToGroupEvent(self, added))
    59             if removed:
    62             if removed:
    60                 print("<< removed =", removed)
    63                 logger.debug("Removed principals {0} from group {1} ({2})".format(str(removed), self.group_id,
       
    64                                                                                   self.title))
    61                 registry.notify(PrincipalsRemovedFromGroupEvent(self, removed))
    65                 registry.notify(PrincipalsRemovedFromGroupEvent(self, removed))
    62 
    66 
    63 
    67 
    64 @implementer(IGroupsFolderPlugin)
    68 @implementer(IGroupsFolderPlugin)
    65 class GroupsFolder(Folder):
    69 class GroupsFolder(Folder):