def checkVersion(self, node): """ Check optional language parameter. """ if node.hasAttribute("version"): value = node.getAttribute("version") if value not in self.wps.versions: raise pywps.VersionNegotiationFailed( 'The requested version "' + value + '" is not supported by this server.') else: self.inputs["version"] = value else: raise pywps.MissingParameterValue("version")
def parse(self, document, initInputs=None): """ Parse the requested XML document""" self.document = document # input DOM if initInputs: self.inputs = initInputs versions = [] # accepted versions acceptedVersionsNodes = None versionNode = None firstChild = self.isSoapFirstChild(self.document) # no comments or owsNameSpace = pywps.OWS_NAMESPACE wpsNameSpace = pywps.WPS_NAMESPACE # # Mandatory options # service & Request are already controlled # # Optional options # acceptVersions acceptedVersionsNodes = self.document.getElementsByTagNameNS( wpsNameSpace, "AcceptVersions") if len(acceptedVersionsNodes) > 0: for versionNode in\ acceptedVersionsNodes[-1].getElementsByTagNameNS(owsNameSpace, "Version"): versions.append(versionNode.firstChild.nodeValue) if len(versions) == 0: versions = self.wps.versions self.inputs["acceptversions"] = versions for version in self.inputs["acceptversions"]: if version in self.wps.versions: self.inputs["version"] = version if not "version" in self.inputs: raise pywps.VersionNegotiationFailed( "There's no version in AcceptVersions parameter " + "that is supported by this server.") # language self.checkLanguage(firstChild) return self.inputs
class Get(GetParser): """ Parses input request obtained via HTTP GET encoding. """ def __init__(self, wps): GetParser.__init__(self, wps) def parse(self, unparsedInputs, initInputs=None): """ Parse rawly parsed inputs """ if initInputs: self.inputs = initInputs self.unparsedInputs = unparsedInputs # # Mandatory options # service & Request are already controlled # # Optional options # AcceptVersions try: self.inputs["acceptversions"] = \ self.unparsedInputs["acceptversions"].split(",") except KeyError, e: self.inputs["acceptversions"] = self.wps.versions for version in self.inputs["acceptversions"]: if version in self.wps.versions: self.inputs["version"] = version if not "version" in self.inputs: raise pywps.VersionNegotiationFailed( "There's no version in AcceptVersions parameter " + "that is supported by this server.") # Language self.checkLanguage() return self.inputs