示例#1
0
文件: wsgiapp.py 项目: zigit/ferenda
    def __init__(self, repos, inifile=None, **kwargs):
        self.repos = repos
        self.log = logging.getLogger("wsgi")

        # FIXME: Cut-n-paste of the method in Resources.__init__
        loadpaths = [ResourceLoader.make_loadpath(repo) for repo in repos]
        loadpath = ["."]  # cwd always has priority -- makes sense?
        for subpath in loadpaths:
            for p in subpath:
                if p not in loadpath:
                    loadpath.append(p)
        self.resourceloader = ResourceLoader(*loadpath)
        # FIXME: need to specify documentroot?
        defaults = DocumentRepository.get_default_options()
        if inifile:
            assert os.path.exists(
                inifile), "INI file %s doesn't exist (relative to %s)" % (
                    inifile, os.getcwd())

        # NB: If both inifile and kwargs are specified, the latter
        # will take precedence. I think this is the expected
        # behaviour.
        self.config = LayeredConfig(Defaults(defaults),
                                    INIFile(inifile),
                                    Defaults(kwargs),
                                    cascade=True)
示例#2
0
 def __init__(self, repos, resourcedir, **kwargs):
     # FIXME: document what kwargs could be (particularly 'combineresources')
     self.repos = repos
     self.resourcedir = resourcedir
     from ferenda.manager import DEFAULT_CONFIG
     defaults = dict(DEFAULT_CONFIG)
     defaults.update(DocumentRepository.get_default_options())
     defaults.update(kwargs)
     self.config = LayeredConfig(Defaults(defaults))
     # the below call to setup_logger alters the logging level of
     # the root logger, which can't be good practice. Also, we
     # should probably not log to the root logger, but rather to
     # ferenda.resources.
     #
     # from ferenda.manager import setup_logger
     # self.log = setup_logger()
     self.log = logging.getLogger("ferenda.resources")
     # FIXME: How should we set up a global loadpath from the
     # individual repos?
     loadpaths = [ResourceLoader.make_loadpath(repo) for repo in repos]
     loadpath = ["."]  # cwd always has priority -- makes sense?
     for subpath in loadpaths:
         for p in subpath:
             if p not in loadpath:
                 loadpath.append(p)
     self.resourceloader = ResourceLoader(*loadpath)
示例#3
0
    def __init__(self, repos, inifile=None, **kwargs):
        self.repos = repos
        self.log = logging.getLogger("wsgi")

        # FIXME: Cut-n-paste of the method in Resources.__init__
        loadpaths = [ResourceLoader.make_loadpath(repo) for repo in repos]
        loadpath = ["."]  # cwd always has priority -- makes sense?
        for subpath in loadpaths:
            for p in subpath:
                if p not in loadpath:
                    loadpath.append(p)
        self.resourceloader = ResourceLoader(*loadpath)
        # FIXME: need to specify documentroot?
        defaults = DocumentRepository.get_default_options()
        if inifile:
            assert os.path.exists(
                inifile), "INI file %s doesn't exist (relative to %s)" % (inifile, os.getcwd())

        # NB: If both inifile and kwargs are specified, the latter
        # will take precedence. I think this is the expected
        # behaviour.
        self.config = LayeredConfig(Defaults(defaults),
                                    INIFile(inifile),
                                    Defaults(kwargs),
                                    cascade=True)
示例#4
0
 def __init__(self, repos, resourcedir, **kwargs):
     # FIXME: document what kwargs could be (particularly 'combineresources')
     self.repos = repos
     self.resourcedir = resourcedir
     defaults = DocumentRepository.get_default_options()
     defaults.update(kwargs)
     self.config = LayeredConfig(Defaults(defaults))
     # the below call to setup_logger alters the logging level of
     # the root logger, which can't be good practice. Also, we
     # should probably not log to the root logger, but rather to
     # ferenda.resources.
     #
     # from ferenda.manager import setup_logger
     # self.log = setup_logger()
     self.log = logging.getLogger("ferenda.resources")
     # FIXME: How should we set up a global loadpath from the
     # individual repos?
     loadpaths = [ResourceLoader.make_loadpath(repo) for repo in repos]
     loadpath = ["."]  # cwd always has priority -- makes sense?
     for subpath in loadpaths:
         for p in subpath:
             if p not in loadpath:
                 loadpath.append(p)
     self.resourceloader = ResourceLoader(*loadpath)