
def membershipStateChange(state_change):
    """Do extra bookkeeping for (de)activated team memberships.

    This will reindex the security for all teamspaces related
    to the team in which the membership is being activated.
    """
    membership=state_change.object
    # The workflow machinery does a reindex after this script runs, but the
    # teamspace security logic uses a catalog search to find active
    # memberships. To get this working we need to force a reindex here
    # first.
    membership.reindexObject()
    membership.getTeam().reindexTeamSpaceSecurity()
