Fire events when principals are added to and removed from group folders

This proposal was originally made on the Zope3-dev mailing list

Status:

IsImplemented rev 41374

Author:

Gary Poster

Problem:

We want to perform actions when a user is added to a group, and possibly when a user is removed from a group. There is no hook point for this currently in the zope.app.authentication code.

Solution:

Fire events in the zope.app.authentication code when principals are added and removed from groups.

    from zope import interface

    def IPrincipalAddedToGroup(interface.Inteface):
        group_id = interface.Attribute(
            'the id of the group to which the principal was added')
        principal_ids = interface.Attribute(
            'an iterable of one or more ids of principals added')

    def IPrincipalRemovedFromGroup(interface.Inteface):
        group_id = interface.Attribute(
            'the id of the group from which the principal was removed')
        principal_ids = interface.Attribute(
            'an iterable of one or more ids of principals removed')

In terms of implementation, it looks like zope.app.authentication.groupfolder.GroupFolder._addPrincipalToGroup and zope.app.authentication.groupfolder.GroupFolder._removePrincipalFromGroup are the methods that would fire the events.

Because a group folder does not itself know the full group_id of the groups it contains without access to its authentication utility, this proposal is contingent on the Allow contained non-utility Pluggable Authentication Utility plugins proposal.

Risks:

I am aware of none.



( 97 subscribers )