'Returns currently set Perspective for the User'

def get_perspective(self):

    ids = []
    try:
        for setting in ModuleSetting.get_for_module('treeio.core', name='default_perspective', user=self):
            ids.append(long(setting.value))
        perspective_id = ids[0]
        perspective = get_object_or_404(Perspective, pk=perspective_id)
    except:
        try:
            perspective = self.default_group.get_perspective()
        except:
            try:
                conf = ModuleSetting.get_for_module('treeio.core', 'default_perspective')[0]
                perspective = Perspective.objects.get(pk=long(conf.value))
            except Exception:
                try:
                    perspective = Perspective.objects.all()[0]
                except:
                    perspective = Perspective(name='Default')
                    perspective.save()
                ModuleSetting.set_for_module('default_perspective', perspective.id, 'treeio.core', user=self)
    return perspective
