示例#1
0
def get_apps(apps_dir, include_apps=None, settings_file='settings.ini', local_settings_file='local_settings.ini'):
    include_apps = include_apps or []
    inifile = norm_path(os.path.join(apps_dir, settings_file))
    apps = []
    visited = set()
    if not os.path.exists(apps_dir):
        return apps
    if os.path.exists(inifile):
        x = pyini.Ini(inifile)
        if x:
            for app in x.GLOBAL.get('INSTALLED_APPS', []):
                apps.extend(list(get_app_depends(app, visited)))

    local_inifile = norm_path(os.path.join(apps_dir, local_settings_file))
    if os.path.exists(local_inifile):
        x = pyini.Ini(local_inifile)
        if x and 'GLOBAL' in x:
            for app in x.GLOBAL.get('INSTALLED_APPS', []):
                apps.extend(list(get_app_depends(app, visited)))

    if not apps and os.path.exists(apps_dir):
        for p in os.listdir(apps_dir):
            if os.path.isdir(os.path.join(apps_dir, p)) and p not in ['.svn', 'CVS', '.git'] and not p.startswith('.') and not p.startswith('_'):
                apps.append(p)
    
    for app in include_apps:
        apps.extend(list(get_app_depends(app, visited)))

    return apps
示例#2
0
def get_apps(apps_dir, include_apps=None, settings_file='settings.ini', local_settings_file='local_settings.ini'):
    include_apps = include_apps or []
    inifile = norm_path(os.path.join(apps_dir, settings_file))
    apps = []
    visited = set()
    if not os.path.exists(apps_dir):
        return apps
    if os.path.exists(inifile):
        x = pyini.Ini(inifile)
        if x:
            for app in x.GLOBAL.get('INSTALLED_APPS', []):
                apps.extend(list(get_app_depends(app, visited)))

    local_inifile = norm_path(os.path.join(apps_dir, local_settings_file))
    if os.path.exists(local_inifile):
        x = pyini.Ini(local_inifile)
        if x and 'GLOBAL' in x:
            for app in x.GLOBAL.get('INSTALLED_APPS', []):
                apps.extend(list(get_app_depends(app, visited)))

    if not apps and os.path.exists(apps_dir):
        for p in os.listdir(apps_dir):
            if os.path.isdir(os.path.join(apps_dir, p)) and p not in ['.svn', 'CVS', '.git'] and not p.startswith('.') and not p.startswith('_'):
                apps.append(p)
    
    for app in include_apps:
        apps.extend(list(get_app_depends(app, visited)))

    return apps
示例#3
0
def get_apps(apps_dir, include_apps=None, settings_file="settings.ini", local_settings_file="local_settings.ini"):
    include_apps = include_apps or []
    inifile = norm_path(os.path.join(apps_dir, settings_file))
    apps = []
    visited = set()
    if not os.path.exists(apps_dir):
        return apps
    if os.path.exists(inifile):
        x = pyini.Ini(inifile)
        if x:
            for app in x.GLOBAL.get("INSTALLED_APPS", []):
                apps.extend(list(get_app_depends(app, visited)))

    local_inifile = norm_path(os.path.join(apps_dir, local_settings_file))
    if os.path.exists(local_inifile):
        x = pyini.Ini(local_inifile)
        if x and "GLOBAL" in x:
            for app in x.GLOBAL.get("INSTALLED_APPS", []):
                apps.extend(list(get_app_depends(app, visited)))

    if not apps and os.path.exists(apps_dir):
        for p in os.listdir(apps_dir):
            if (
                os.path.isdir(os.path.join(apps_dir, p))
                and p not in [".svn", "CVS", ".git"]
                and not p.startswith(".")
                and not p.startswith("_")
            ):
                apps.append(p)

    for app in include_apps:
        apps.extend(list(get_app_depends(app, visited)))

    return apps
示例#4
0
    def init(self, project_dir, apps_dir):
        if not project_dir:
            project_dir = norm_path(os.path.join(apps_dir, '..'))

        Dispatcher.project_dir = project_dir
        Dispatcher.apps_dir = norm_path(os.path.join(project_dir, 'apps'))
        Dispatcher.apps = get_apps(self.apps_dir, self.include_apps,
                                   self.settings_file,
                                   self.local_settings_file)
        Dispatcher.modules = self.collect_modules()

        self.install_settings(self.modules['settings'])

        self.debug = settings.GLOBAL.get('DEBUG', False)

        #process global_objects
        self.install_global_objects()

        #process binds
        self.install_binds()

        dispatch.call(self, 'after_init_settings')

        Dispatcher.settings = settings

        #process domains
        self.process_domains(settings)

        #setup log
        self.set_log()

        #set app rules
        rules.set_app_rules(dict(settings.get('URL', {})))
        rules.set_urlroute_rules(dict(settings.get('URL_ROUTE', {})))

        Dispatcher.env = self._prepare_env()
        Dispatcher.template_dirs = self.get_template_dirs()
        Dispatcher.template_loader = self.install_template_loader(
            Dispatcher.template_dirs)

        #begin to start apps
        self.install_apps()
        dispatch.call(self, 'after_init_apps')
        #process views
        self.install_views(self.modules['views'])
        #process exposes
        self.install_exposes()
        #process middlewares
        Dispatcher.middlewares = self.install_middlewares()

        dispatch.call(self, 'prepare_default_env', Dispatcher.env)
        Dispatcher.default_template = pkg.resource_filename(
            'uliweb.core', 'default.html')

        Dispatcher.installed = True
示例#5
0
    def init(self, project_dir, apps_dir):
        if not project_dir:
            project_dir = norm_path(os.path.join(apps_dir, '..'))
        
        Dispatcher.project_dir = project_dir
        Dispatcher.apps_dir = norm_path(os.path.join(project_dir, 'apps'))
        Dispatcher.apps = get_apps(self.apps_dir, self.include_apps, self.settings_file, self.local_settings_file)
        Dispatcher.modules = self.collect_modules()

        self.install_settings(self.modules['settings'])

        self.debug = settings.GLOBAL.get('DEBUG', False)

        #process global_objects
        self.install_global_objects()
        
        #process binds
        self.install_binds()
        
        dispatch.call(self, 'after_init_settings')
        
        Dispatcher.settings = settings
        
        #process domains
        self.process_domains(settings)
        
        #setup log
        self.set_log()
        
        #set app rules
        rules.set_app_rules(dict(settings.get('URL', {})))
        rules.set_urlroute_rules(dict(settings.get('URL_ROUTE', {})))

        Dispatcher.env = self._prepare_env()
        Dispatcher.template_dirs = self.get_template_dirs()
        Dispatcher.template_loader = self.install_template_loader(Dispatcher.template_dirs)

        #begin to start apps
        self.install_apps()
        dispatch.call(self, 'after_init_apps')
        #process views
        self.install_views(self.modules['views'])
        #process exposes
        self.install_exposes()
        #process middlewares
        Dispatcher.middlewares = self.install_middlewares()

        dispatch.call(self, 'prepare_default_env', Dispatcher.env)
        Dispatcher.default_template = pkg.resource_filename('uliweb.core', 'default.html')
        
        Dispatcher.installed = True
示例#6
0
    def init(self, project_dir, apps_dir):
        if not project_dir:
            project_dir = norm_path(os.path.join(apps_dir, ".."))
        Dispatcher.project_dir = project_dir
        Dispatcher.apps_dir = norm_path(os.path.join(project_dir, "apps"))
        Dispatcher.apps = get_apps(self.apps_dir, self.include_apps, self.settings_file, self.local_settings_file)
        Dispatcher.modules = self.collect_modules()

        self.install_settings(self.modules["settings"])

        # process global_objects
        self.install_global_objects()

        # process binds
        self.install_binds()

        dispatch.call(self, "after_init_settings")

        Dispatcher.settings = settings

        # process domains
        self.process_domains(settings)

        # setup log
        self.set_log()

        # set app rules
        rules.set_app_rules(dict(settings.get("URL", {})))

        Dispatcher.env = self._prepare_env()
        Dispatcher.template_dirs = self.get_template_dirs()
        Dispatcher.template_processors = {}
        self.install_template_processors()

        # begin to start apps
        self.install_apps()
        dispatch.call(self, "after_init_apps")
        # process views
        self.install_views(self.modules["views"])
        # process exposes
        self.install_exposes()
        # process middlewares
        Dispatcher.middlewares = self.install_middlewares()

        self.debug = settings.GLOBAL.get("DEBUG", False)
        dispatch.call(self, "prepare_default_env", Dispatcher.env)
        Dispatcher.default_template = pkg.resource_filename("uliweb.core", "default.html")

        Dispatcher.installed = True
示例#7
0
def get_apps(apps_dir, include_apps=None, settings_file='settings.ini', local_settings_file='local_settings.ini'):
    include_apps = include_apps or []
    inifile = norm_path(os.path.join(apps_dir, settings_file))
    apps = []
    if not os.path.exists(apps_dir):
        return apps
    if os.path.exists(inifile):
        x = cache_get(inifile, lambda x:pyini.Ini(x), 'ini')
        if x:
            apps = x.GLOBAL.get('INSTALLED_APPS', [])
    local_inifile = norm_path(os.path.join(apps_dir, local_settings_file))
    if os.path.exists(local_inifile):
        x = cache_get(local_inifile, lambda x:pyini.Ini(x), 'ini')
        if x and 'GLOBAL' in x:
            apps = x.GLOBAL.get('INSTALLED_APPS', apps)
    if not apps and os.path.exists(apps_dir):
        for p in os.listdir(apps_dir):
            if os.path.isdir(os.path.join(apps_dir, p)) and p not in ['.svn', 'CVS', '.git'] and not p.startswith('.') and not p.startswith('_'):
                apps.append(p)
    
    #process app alias
    #the app alias defined as ('current package name', 'alias appname')
    for i, a in enumerate(apps):
        if isinstance(a, (tuple, list)):
            apps[i] = a[0]
            __app_alias__[a[1]+'.'] = a[0] + '.'
            
    apps.extend(include_apps)
    #process dependencies
    s = apps[:]
    visited = set()
    while s:
        p = s.pop()
        if p in visited:
            continue
        else:
            configfile = os.path.join(get_app_dir(p), 'config.ini')
            
            if os.path.exists(configfile):
                x = pyini.Ini(configfile)
                for i in x.get_var('DEFAULT/REQUIRED_APPS', []):
                    if i not in apps:
                        apps.append(i)
                    if i not in visited:
                        s.append(i)
            visited.add(p)

    return apps
示例#8
0
    def init(self, project_dir, apps_dir):
        if not project_dir:
            project_dir = norm_path(os.path.join(apps_dir, '..'))
        conf.project_dir = project_dir
        conf.apps_dir = norm_path(os.path.join(project_dir, 'apps'))
        Dispatcher.project_dir = project_dir
        Dispatcher.apps_dir = conf.apps_dir
        Dispatcher.apps = get_apps(self.apps_dir, self.include_apps, self.settings_file, self.local_settings_file)
        Dispatcher.modules = self.collect_modules()
        
        self.install_settings(self.modules['settings'])
        Dispatcher.settings = conf.settings
        
        #setup log
        self.set_log()
        
        #set app rules
        rules.set_app_rules(dict(conf.settings.get('URL', {})))
        
        Dispatcher.env = self._prepare_env()
        Dispatcher.template_dirs = self.get_template_dirs()
        
        #begin to start apps
        self.install_apps()
        
        dispatch.call(self, 'after_init_apps')

        Dispatcher.url_map = conf.url_map
        self.install_views(self.modules['views'])
        #process dispatch hooks
        self.dispatch_hooks()
        
        self.debug = conf.settings.GLOBAL.get('DEBUG', False)
        dispatch.call(self, 'prepare_default_env', Dispatcher.env)
        Dispatcher.default_template = pkg.resource_filename('uliweb.core', 'default.html')
        
        Dispatcher.installed = True