def execute(self, application): settings.configure(config) application.settings = settings.to_dict() application.settings['installed_apps'] += ('workin.exts.admin',) logging.debug("Add 'workin.exts.admin' to INSTALLED_APPS.") application.settings['template_dirs'] += (config.ADMIN_TEMPLATE_PATH, ) ADMIN_HANDLERS = ( url(r'/admin/static/(.*)', StaticFileHandler, {'path': application.settings['admin_static_path']}, name='admin-static-url'), url(r'/admin/list/(?P<model>[^\/]+)/(?P<page>\d+)/', AdminListHandler, name='admin-list'), url(r'/admin/edit/(?P<model>[^\/]+)/(?P<id>\d+)/', AdminEditHandler, name='admin-edit'), url(r'/admin/add/(?P<model>[^\/]+)/', AdminAddHandler, name='admin-add'), url(r'/admin/detail/(?P<model>[^\/]+)/(?P<id>\d+)/', AdminDetailHandler, name='admin-detail'), url(r'/admin/', AdminDashboardHandler, name='admin-dashboard'), ) application.handlers.extend(ADMIN_HANDLERS) logging.debug("Add admin handlers for extension 'workin.exts.admin'.") for app in application.settings['installed_apps']: try: importlib.import_module(app + '.admin') except ImportError: # No admin.py for the specified app pass
def execute(self, application): settings.configure(config) application.settings = settings.to_dict() application.settings["installed_apps"] += ("workin.exts.admin",) logging.debug("Add 'workin.exts.admin' to INSTALLED_APPS.") application.settings["template_dirs"] += (config.ADMIN_TEMPLATE_PATH,) ADMIN_HANDLERS = ( url( r"/admin/static/(.*)", StaticFileHandler, {"path": application.settings["admin_static_path"]}, name="admin-static-url", ), url(r"/admin/list/(?P<model>[^\/]+)/(?P<page>\d+)/", AdminListHandler, name="admin-list"), url(r"/admin/edit/(?P<model>[^\/]+)/(?P<id>\d+)/", AdminEditHandler, name="admin-edit"), url(r"/admin/add/(?P<model>[^\/]+)/", AdminAddHandler, name="admin-add"), url(r"/admin/detail/(?P<model>[^\/]+)/(?P<id>\d+)/", AdminDetailHandler, name="admin-detail"), url(r"/admin/", AdminDashboardHandler, name="admin-dashboard"), ) application.handlers.extend(ADMIN_HANDLERS) logging.debug("Add admin handlers for extension 'workin.exts.admin'.") for app in application.settings["installed_apps"]: try: importlib.import_module(app + ".admin") except ImportError: # No admin.py for the specified app pass
def find_extensions(ext_module): ext_class = None try: ext_class = importlib.import_module(ext_module + '.discover') except ImportError, e: logging.exception("Error found while discovering workin " "extension '%s': %s" % (ext_module, e)) raise
def configure(self, settings_module=None, override=False): self.set_module_value(global_settings) # Override with user custom settings. if settings_module: if isinstance(settings_module, basestring): try: settings_module = importlib.import_module(settings_module) except ImportError: logging.exception("Cannot import settings '%s'. (Is is in \ sys.path?)" % (settings_module)) self.set_module_value(settings_module, override) if not self.__dict__.get('COOKIE_SECRET'): warnings.warn("The COOKIE_SECRET settings must not be empty.", DeprecationWarning) return self
def configure(self, settings_module=None, override=False): self.set_module_value(global_settings) # Override with user custom settings. if settings_module: if isinstance(settings_module, basestring): try: settings_module = importlib.import_module(settings_module) except ImportError: logging.exception( "Cannot import settings '%s'. (Is is in \ sys.path?)" % (settings_module) ) self.set_module_value(settings_module, override) if not self.__dict__.get("COOKIE_SECRET"): warnings.warn("The COOKIE_SECRET settings must not be empty.", DeprecationWarning) return self