'Raise events for publish and retraction notifications.'

def _handle_event_items(self, msg):

    node = msg['pubsub_event']['items']['node']
    multi = (len(msg['pubsub_event']['items']) > 1)
    values = {}
    if multi:
        values = msg.values
        del values['pubsub_event']
    for item in msg['pubsub_event']['items']:
        event_name = self.node_event_map.get(node, None)
        event_type = 'publish'
        if (item.name == 'retract'):
            event_type = 'retract'
        if multi:
            condensed = self.xmpp.Message()
            condensed.values = values
            condensed['pubsub_event']['items']['node'] = node
            condensed['pubsub_event']['items'].append(item)
            self.xmpp.event(('pubsub_%s' % event_type), msg)
            if event_name:
                self.xmpp.event(('%s_%s' % (event_name, event_type)), condensed)
        else:
            self.xmpp.event(('pubsub_%s' % event_type), msg)
            if event_name:
                self.xmpp.event(('%s_%s' % (event_name, event_type)), msg)
