'Helper method for publishing events when children blocks are
selected/updated for a user.  This helper is also used by
the ContentLibraryTransformer.
Arguments:
block_keys -
A dict describing which events to publish (add or
remove), see `make_selection` above for format details.
format_block_keys -
A function to convert block keys to the format expected
by publish_event. Must have the signature:
[(block_type, block_id)] -> T
Where T is a collection of block keys as accepted by
`publish_event`.
publish_event -
Function that handles the actual publishing.  Must have
the signature:
<\'removed\'|\'assigned\'> -> result:T -> removed:T -> reason:basestring -> None
Where T is a collection of block_keys as returned by
`format_block_keys`.'

@classmethod
def publish_selected_children_events(cls, block_keys, format_block_keys, publish_event):

    if block_keys['invalid']:
        publish_event('removed', result=format_block_keys(block_keys['selected']), removed=format_block_keys(block_keys['invalid']), reason='invalid')
    if block_keys['overlimit']:
        publish_event('removed', result=format_block_keys(block_keys['selected']), removed=format_block_keys(block_keys['overlimit']), reason='overlimit')
    if block_keys['added']:
        publish_event('assigned', result=format_block_keys(block_keys['selected']), added=format_block_keys(block_keys['added']))
