Exemplo n.º 1
0
 def register_menu(self, menu):
     from menus.base import Menu
     assert issubclass(menu, Menu)
     if menu.__name__ in self.menus.keys():
         raise NamespaceAlreadyRegistered(
             "[%s] a menu with this name is already registered" %
             menu.__name__)
     self.menus[menu.__name__] = menu()
Exemplo n.º 2
0
 def register_menu(self, menu_cls):
     from menus.base import Menu
     assert issubclass(menu_cls, Menu)
     if menu_cls.__name__ in self.menus:
         raise NamespaceAlreadyRegistered(
             "[{0}] a menu with this name is already registered".format(
                 menu_cls.__name__))
     # Note: menu_cls should still be the menu CLASS at this point.
     self.menus[menu_cls.__name__] = menu_cls
Exemplo n.º 3
0
 def register_menu(self, menu_cls):
     from menus.base import Menu
     assert issubclass(menu_cls, Menu)
     # If we should register a menu after we've already expanded the existing
     # ones, we need to mark it as such.
     self._expanded = False
     if menu_cls.__name__ in self.menus.keys():
         raise NamespaceAlreadyRegistered(
             "[{0}] a menu with this name is already registered".format(
                 menu_cls.__name__))
     # Note: menu_cls should still be the menu CLASS at this point. It will
     # be instantiated in self._expand_menus().
     self.menus[menu_cls.__name__] = menu_cls
Exemplo n.º 4
0
    def register_menu(self, menu_cls):
        import warnings

        if menu_cls.__module__.split('.')[-1] == 'menu':
            warnings.warn(
                'menu.py filename is deprecated, '
                'and it will be removed in version 3.5; '
                'please rename it to cms_menus.py', DeprecationWarning)
        from menus.base import Menu
        assert issubclass(menu_cls, Menu)
        if menu_cls.__name__ in self.menus:
            raise NamespaceAlreadyRegistered(
                "[{0}] a menu with this name is already registered".format(
                    menu_cls.__name__))
        # Note: menu_cls should still be the menu CLASS at this point.
        self.menus[menu_cls.__name__] = menu_cls
Exemplo n.º 5
0
    def register_menu(self, menu_cls):
        import warnings

        if menu_cls.__module__.split('.')[-1] == 'menu':
            warnings.warn(
                'menu.py filename is deprecated, '
                'and it will be removed in version 3.4; '
                'please rename it to cms_menus.py', DeprecationWarning)
        from menus.base import Menu
        assert issubclass(menu_cls, Menu)
        # If we should register a menu after we've already expanded the existing
        # ones, we need to mark it as such.
        self._expanded = False
        if menu_cls.__name__ in self.menus.keys():
            raise NamespaceAlreadyRegistered(
                "[{0}] a menu with this name is already registered".format(
                    menu_cls.__name__))
        # Note: menu_cls should still be the menu CLASS at this point. It will
        # be instantiated in self._expand_menus().
        self.menus[menu_cls.__name__] = menu_cls