def test_load_handlers(self): """Test that handlers can be loaded correctly. We use a mock working set, since by default no handlers are installed with Pydap. """ handlers = load_handlers(MockWorkingSet()) self.assertTrue(MockHandler in handlers)
def test_load_handlers(self): """Test that handlers can be loaded correctly. We use a mock working set, since by default no handlers are installed with pydap. """ handlers = load_handlers(MockWorkingSet()) self.assertTrue(MockHandler in handlers)
def __init__(self, root, templates='templates', catalog='catalog.xml', **config): self.root = root.replace('/', os.path.sep) self.catalog = catalog self.config = config loader = FileLoader(templates) self.renderer = GenshiRenderer( options={}, loader=loader) self.handlers = load_handlers()
def __init__(self, path, templates=None): self.path = os.path.abspath(path) # the default loader reads templates from the package loaders = [PackageLoader("pydap.wsgi", "templates")] # optionally, the user can also specify a template directory that will # override the default templates; this should have precedence over the # default templates if templates is not None: loaders.insert(0, FileSystemLoader(templates)) # set the rendering environment; this is also used by pydap responses # that need to render templates (like HTML, WMS, KML, etc.) self.env = Environment(loader=ChoiceLoader(loaders)) self.env.filters["datetimeformat"] = datetimeformat self.env.filters["unquote"] = unquote # cache available handlers, so we don't need to load them every request self.handlers = load_handlers()
def __init__(self, root, templates='templates', catalog='catalog.xml', **config): self.root = root.replace('/', os.path.sep) self.catalog = catalog # Regex for filtering out files and directories file_filter_regex = config.get('file_filter_regex') if file_filter_regex: self.file_filter = re.compile(file_filter_regex) # Boolean option to determines whether a hidden file or directory is served # Defaults to serve all, regardless of filter self.filter_restrict = config.get('restrict_with_filter', False) false_strings = {'False', 'false', '0'} if self.filter_restrict in false_strings: self.filter_restrict = False self.config = config loader = FileLoader(templates) self.renderer = GenshiRenderer( options={}, loader=loader) self.handlers = load_handlers()
def test_get_handler(self): """Test that we can load a specific handler.""" handlers = load_handlers(MockWorkingSet()) handler = get_handler("file.foo", handlers) self.assertIsInstance(handler, MockHandler)