def get_store(self, name, workspace=None): #stores = [s for s in self.get_stores(workspace) if s.name == name] if workspace is None: store = None for ws in self.get_workspaces(): found = None try: found = self.get_store(name, ws) except: # don't expect every workspace to contain the named store pass if found: if store: raise AmbiguousRequestError( "Multiple stores found named: " + name) else: store = found if not store: raise FailedRequestError("No store found named: " + name) return store else: # workspace is not None if isinstance(workspace, basestring): workspace = self.get_workspace(workspace) if workspace is None: return None logger.debug("datastore url is [%s]", workspace.datastore_url) ds_list = self.get_xml(workspace.datastore_url) cs_list = self.get_xml(workspace.coveragestore_url) datastores = [ n for n in ds_list.findall("dataStore") if n.find("name").text == name ] coveragestores = [ n for n in cs_list.findall("coverageStore") if n.find("name").text == name ] ds_len, cs_len = len(datastores), len(coveragestores) if ds_len == 1 and cs_len == 0: return datastore_from_index(self, workspace, datastores[0]) elif ds_len == 0 and cs_len == 1: return coveragestore_from_index(self, workspace, coveragestores[0]) elif ds_len == 0 and cs_len == 0: raise FailedRequestError("No store found in " + str(workspace) + " named: " + name) else: raise AmbiguousRequestError( str(workspace) + " and name: " + name + " do not uniquely identify a layer")
def get_stores(self, workspace=None): if workspace is not None: if isinstance(workspace, basestring): workspace = self.get_workspace(workspace) ds_list = self.get_xml(workspace.datastore_url) cs_list = self.get_xml(workspace.coveragestore_url) datastores = [datastore_from_index(self, workspace, n) for n in ds_list.findall("dataStore")] coveragestores = [coveragestore_from_index(self, workspace, n) for n in cs_list.findall("coverageStore")] return datastores + coveragestores else: stores = [] for ws in self.get_workspaces(): a = self.get_stores(ws) stores.extend(a) return stores
def get_stores(self, workspace=None): if workspace is not None: if isinstance(workspace, basestring): workspace = self.get_workspace(workspace) ds_list = self.get_xml(workspace.datastore_url) cs_list = self.get_xml(workspace.coveragestore_url) datastores = [ datastore_from_index(self, workspace, n) for n in ds_list.findall("dataStore") ] coveragestores = [ coveragestore_from_index(self, workspace, n) for n in cs_list.findall("coverageStore") ] return datastores + coveragestores else: stores = [] for ws in self.get_workspaces(): a = self.get_stores(ws) stores.extend(a) return stores
def get_store(self, name, workspace=None): #stores = [s for s in self.get_stores(workspace) if s.name == name] if workspace is None: store = None for ws in self.get_workspaces(): found = None try: found = self.get_store(name, ws) except: # don't expect every workspace to contain the named store pass if found: if store: raise AmbiguousRequestError("Multiple stores found named: " + name) else: store = found if not store: raise FailedRequestError("No store found named: " + name) return store else: # workspace is not None if isinstance(workspace, basestring): workspace = self.get_workspace(workspace) if workspace is None: return None logger.debug("datastore url is [%s]", workspace.datastore_url ) ds_list = self.get_xml(workspace.datastore_url) cs_list = self.get_xml(workspace.coveragestore_url) datastores = [n for n in ds_list.findall("dataStore") if n.find("name").text == name] coveragestores = [n for n in cs_list.findall("coverageStore") if n.find("name").text == name] ds_len, cs_len = len(datastores), len(coveragestores) if ds_len == 1 and cs_len == 0: return datastore_from_index(self, workspace, datastores[0]) elif ds_len == 0 and cs_len == 1: return coveragestore_from_index(self, workspace, coveragestores[0]) elif ds_len == 0 and cs_len == 0: raise FailedRequestError("No store found in " + str(workspace) + " named: " + name) else: raise AmbiguousRequestError(str(workspace) + " and name: " + name + " do not uniquely identify a layer")