code: def publish(event_type: str,
              event_data: dict = None,
              object_type: str = None,
              object_id: str = None,
              object_key: str = None,
              origin: str = None):
      
      event = Event(event_id=_get_event_id(object_type),
                    event_type=event_type,
                    event_data=event_data,
                    event_origin=origin,
                    object_type=object_type,
                    object_id=object_id,
                    object_key=object_key)
  
      # Publish the event to subscribers
      _publish_to_subscribers(event)
  
      # Update the object event list and data.
      if object_key is None:
          object_key = '{}:{}'.format(object_type, object_id)
      _update_object(object_key, event)
  
      # Execute the set of db transactions as an atomic transaction.
      DB.execute()
docs: Publish an event.
  
      Published the event to all subscribers and stores the event with the
      object.
  
      Args:
          event_type (str): The event type
          event_data (dict, optional): Optional event data
          object_type (str): Type of object.
          object_id (str): Object ID
          object_key (str, optional): Key used to stored the object. If None,
              the default assume the key is of the form <object type>:<object id>
          origin (str): Origin or publisher of the event.