'Set the system to use a certain named profile. The profile
must have already been loaded into the Profiles collection.'

def set_profile(self, profile_name):

    old_parent = self.get_parent()
    if ((profile_name in ['delete', 'None', '~', '']) or (profile_name is None)):
        self.profile = ''
        if isinstance(old_parent, item.Item):
            old_parent.children.pop(self.name, 'pass')
        return
    self.image = ''
    p = self.collection_mgr.profiles().find(name=profile_name)
    if (p is not None):
        self.profile = profile_name
        self.depth = (p.depth + 1)
        if isinstance(old_parent, item.Item):
            old_parent.children.pop(self.name, 'pass')
        new_parent = self.get_parent()
        if isinstance(new_parent, item.Item):
            new_parent.children[self.name] = self
        return
    raise CX((_('invalid    profile    name:    %s') % profile_name))
