def getConfigurationOption(self, section, key, params): configSection = config.getConfig().get(section) if configSection is None: raise ResourcePathNotFound('No section with that name exists.') elif key not in configSection: raise ResourcePathNotFound('No key with that name exists.') else: return configSection.get(key)
def _lookUpPath(self, path, user=None, test=False, filter=True, force=False): """ Look up a resource in the data hierarchy by path. :param path: path of the resource :param user: user with correct privileges to access path :param test: defaults to false, when set to true will return None instead of throwing exception when path doesn't exist :type test: bool :param filter: Whether the returned model should be filtered. :type filter: bool :param force: if True, don't validate the access. :type force: bool """ path = path.lstrip("/") pathArray = split(path) try: document, model = self._get_base(pathArray, test=test) except EmptyDocument: return {"model": None, "document": None} try: if not force: ModelImporter.model(model).requireAccess(document, user) for i, token in enumerate(pathArray[2:]): # noqa document, model = lookUpToken(token, model, document) if not force: ModelImporter.model(model).requireAccess(document, user) if "fsPath" in document: break if token != pathArray[-1]: document, model = self._get_vobject(document, path, i) except (ValidationException, AccessException): if test: return {"model": None, "document": None} raise ResourcePathNotFound("Path not found: %s" % path) if filter: document = ModelImporter.model(model).filter(document, user) return {"model": model, "document": document}
def _lookup_err(msg, test=False): if test: raise EmptyDocument else: raise ResourcePathNotFound(msg)