'Helper method to publish an event for analytics purposes'

def _publish_event(self, event_name, result, **kwargs):

    event_data = {'location': unicode(self.location), 'result': result, 'previous_count': getattr(self, '_last_event_result_count', len(self.selected)), 'max_count': self.max_count}
    event_data.update(kwargs)
    self.runtime.publish(self, 'edx.librarycontentblock.content.{}'.format(event_name), event_data)
    self._last_event_result_count = len(result)
