def register(self, app=None, discovering_apps=False): # allow use as a decorator if app is None: return lambda app: self.register(app, discovering_apps) if self.apphooks and not discovering_apps: return app if app.__name__ in self.apps: raise AppAlreadyRegistered( 'A CMS application %r is already registered' % app.__name__) if not issubclass(app, CMSApp): raise ImproperlyConfigured( 'CMS application must inherit from cms.app_base.CMSApp, ' 'but %r does not' % app.__name__) if not hasattr(app, 'menus') and hasattr(app, 'menu'): warnings.warn( "You define a 'menu' attribute on CMS application %r, " "but the 'menus' attribute is empty, did you make a typo?" % app.__name__) self.apps[app.__name__] = app return app
def register(self, app=None, discovering_apps=False): # allow use as a decorator if app is None: return lambda app: self.register(app, discovering_apps) if app.__module__.split('.')[-1] == 'cms_app': warnings.warn( 'cms_app.py filename is deprecated, ' 'and it will be removed in version 3.4; ' 'please rename it to cms_apps.py', DeprecationWarning) if self.apphooks and not discovering_apps: return app if app.__name__ in self.apps: raise AppAlreadyRegistered( 'A CMS application %r is already registered' % app.__name__) if not issubclass(app, CMSApp): raise ImproperlyConfigured( 'CMS application must inherit from cms.app_base.CMSApp, ' 'but %r does not' % app.__name__) if not hasattr(app, 'menus') and hasattr(app, 'menu'): warnings.warn("You define a 'menu' attribute on CMS application " "%r, but the 'menus' attribute is empty, " "did you make a typo?" % app.__name__) self.apps[app.__name__] = app() return app
def register(self, app): if self.block_register: return from cms.app_base import CMSApp # validate the app if not issubclass(app, CMSApp): raise ImproperlyConfigured('CMS Apps must inherit ' 'cms.app_base.CMSApp, %r does not' % app) if hasattr(app, 'menu') and not app.menus: warnings.warn("You define a 'menu' attribute on your CMS App %r, " "but the 'menus' attribute is empty, did you make a typo?") name = app.__name__ if name in self.apps.keys(): raise AppAlreadyRegistered("[%s] a cms app with this name is already registered" % name) self.apps[name] = app