'Returns all registered menu classes.
:param for_rendering: Flag that when True forces us to include
all CMSAttachMenu subclasses, even if they\'re not attached.'

def get_registered_menus(self, for_rendering=False):

    self.discover_menus()
    registered_menus = {}
    for (menu_class_name, menu_cls) in self.menus.items():
        if isinstance(menu_cls, Menu):
            menu_cls = menu_cls.__class__
        if hasattr(menu_cls, 'get_instances'):
            _get_menu_class = partial(_get_menu_class_for_instance, menu_cls)
            instances = (menu_cls.get_instances() or [])
            for instance in instances:
                namespace = '{0}:{1}'.format(menu_class_name, instance.pk)
                registered_menus[namespace] = _get_menu_class(instance)
            if ((not instances) and (not for_rendering)):
                registered_menus[menu_class_name] = menu_cls
        elif hasattr(menu_cls, 'get_nodes'):
            registered_menus[menu_class_name] = menu_cls
        else:
            raise ValidationError("Something    was    registered    as    a    menu,    but    isn't.")
    return registered_menus
