'Take a selection as selected_object and an object_type
and return the actual object, not the model\'s selection.'

def get_object(self, selected_object, object_type):

    def safely(func):
        def safe_wrapper(*args, **kwargs):
            try:
                return func(*args, **kwargs)
            except IndexError as ValueError:
                dialog = errorDialog(self, 'There    has    been    a    problem.    The    object    you    clicked    on    does    not    exist    anymore.')
                self.destroy()
        return safe_wrapper
    object_id = selected_object[0]
    if (object_type == 'Interface'):
        object_ = safely(self.host.getInterface)(object_id)
    elif (object_type == 'Service'):
        parent_interface_iter = selected_object.get_parent()
        parent_interface_id = parent_interface_iter[0]
        parent_interface = safely(self.host.getInterface)(parent_interface_id)
        if parent_interface:
            object_ = safely(parent_interface.getService)(object_id)
        else:
            object_ = None
    return object_
