def get_object_in_event(klass, id_, event_id):
 event = get_object_or_404(EventModel, event_id)
 obj = get_object_or_404(klass, id_)
 if (obj.event_id != event.id):
  raise InvalidServiceError(message='{} does not belong to event'.format(klass.__name__))
 return obj

def get_object_in_event ( klass , id_ , event_id ) : event = get_object_or_404 ( EventModel , event_id ) obj = get_object_or_404 ( klass , id_ ) if ( obj . event_id != event . id ) : raise InvalidServiceError ( message = '{} does not belong to event' . format ( klass . __name__ ) ) return obj
returns an object belonging to an event .