[Pywps-commits] r959 - in trunk/pywps: . Parser

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Jul 1 11:07:47 CEST 2010


Author: jachym
Date: 2010-07-01 11:07:46 +0200 (Thu, 01 Jul 2010)
New Revision: 959

Modified:
   trunk/pywps/Parser/DescribeProcess.py
   trunk/pywps/Soap.py
Log:
some fixes for soap, thanks to Arnaud de Groof

Modified: trunk/pywps/Parser/DescribeProcess.py
===================================================================
--- trunk/pywps/Parser/DescribeProcess.py	2010-06-29 14:13:19 UTC (rev 958)
+++ trunk/pywps/Parser/DescribeProcess.py	2010-07-01 09:07:46 UTC (rev 959)
@@ -1,111 +1,110 @@
-"""
-This module parses OGC Web Processing Service (WPS) DescribeProcess request.
-"""
-# Author:	Jachym Cepicky
-#        	http://les-ejk.cz
-#               jachym at les-ejk dot cz
-# Lince:
-#
-# Web Processing Service implementation
-# Copyright (C) 2006 Jachym Cepicky
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-
-import xml.dom.minidom
-import pywps
-from pywps.Parser.Post import Post as PostParser
-from pywps.Parser.Get import Get as GetParser
-
-class Post(PostParser):
-    """
-    Parses input request obtained via HTTP POST encoding - should be XML
-    file.
-    """
-    def __init__(self,wps):
-        PostParser.__init__(self,wps)
-
-    def parse(self,document, initInputs = None):
-
-        if initInputs:
-            self.inputs = initInputs
-
-        self.document = document  # input DOM
-
-        firstChild = self.isSoapFirstChild(self.document)  # no comments or
-
-        owsNameSpace = pywps.OWS_NAMESPACE
-        identifiers = []
-        identifierNode = None
-
-        #
-        # Mandatory options
-
-        # service & Request are already controlled
-
-        # version
-        self.checkVersion(firstChild)
-
-        # identifiers
-        for identifierNode in self.document.getElementsByTagNameNS(
-                owsNameSpace,"Identifier"):
-            identifiers.append(identifierNode.firstChild.nodeValue)
-        if len(identifiers) == 0:
-            raise pywps.MissingParameterValue("Identifier")
-        self.inputs["identifier"] = identifiers
-
-        #
-        # Optional options
-
-        # 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 given raw inputs"""
-
-        if initInputs:
-            self.inputs = initInputs
-
-        self.unparsedInputs = unparsedInputs
-
-        #
-        # Mandatory options
-
-        # service & Request are already controlled
-
-        # version
-        self.checkVersion()
-
-        # identifier
-        if "identifier" in self.unparsedInputs:
-            self.inputs["identifier"] = self.unparsedInputs["identifier"].split(",")
-        else:
-            raise pywps.MissingParameterValue("identifier")
-
-        #
-        # Optional options
-
-        # Language
-        self.checkLanguage()
-
-        return self.inputs
+"""
+This module parses OGC Web Processing Service (WPS) DescribeProcess request.
+"""
+# Author:	Jachym Cepicky
+#        	http://les-ejk.cz
+#               jachym at les-ejk dot cz
+# Lince:
+#
+# Web Processing Service implementation
+# Copyright (C) 2006 Jachym Cepicky
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+import xml.dom.minidom
+import pywps
+from pywps.Parser.Post import Post as PostParser
+from pywps.Parser.Get import Get as GetParser
+
+class Post(PostParser):
+    """
+    Parses input request obtained via HTTP POST encoding - should be XML
+    file.
+    """
+    def __init__(self,wps):
+        PostParser.__init__(self,wps)
+
+    def parse(self,document, initInputs = None):
+
+        if initInputs:
+            self.inputs = initInputs
+
+        self.document = document  # input DOM
+
+	firstChild = self.isSoapFirstChild(self.document)
+	owsNameSpace = pywps.OWS_NAMESPACE
+        identifiers = []
+        identifierNode = None
+
+        #
+        # Mandatory options
+
+        # service & Request are already controlled
+
+        # version
+        self.checkVersion(firstChild)
+
+        # identifiers
+        for identifierNode in self.document.getElementsByTagNameNS(
+                owsNameSpace,"Identifier"):
+            identifiers.append(identifierNode.firstChild.nodeValue)
+        if len(identifiers) == 0:
+            raise pywps.MissingParameterValue("Identifier")
+        self.inputs["identifier"] = identifiers
+
+        #
+        # Optional options
+
+        # 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 given raw inputs"""
+
+        if initInputs:
+            self.inputs = initInputs
+
+        self.unparsedInputs = unparsedInputs
+
+        #
+        # Mandatory options
+
+        # service & Request are already controlled
+
+        # version
+        self.checkVersion()
+
+        # identifier
+        if "identifier" in self.unparsedInputs:
+            self.inputs["identifier"] = self.unparsedInputs["identifier"].split(",")
+        else:
+            raise pywps.MissingParameterValue("identifier")
+
+        #
+        # Optional options
+
+        # Language
+        self.checkLanguage()
+
+        return self.inputs

Modified: trunk/pywps/Soap.py
===================================================================
--- trunk/pywps/Soap.py	2010-06-29 14:13:19 UTC (rev 958)
+++ trunk/pywps/Soap.py	2010-07-01 09:07:46 UTC (rev 959)
@@ -1,89 +1,87 @@
-"""
-SOAP
-----
-SOAP wrapper 
-"""
-# Author:	Jachym Cepicky
-#        	http://les-ejk.cz
-# License:
-#
-# Web Processing Service implementation
-# Copyright (C) 2006 Jachym Cepicky
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-
-from xml.dom import minidom
-
-soap_env_NS = ("http://www.w3.org/2003/05/soap-envelope","http://schemas.xmlsoap.org/soap/envelope/")
-soap_enc_NS = ("http://www.w3.org/2003/05/soap-encoding","http://schemas.xmlsoap.org/soap/encoding/")
-
-SOAP_ENVELOPE="""<?xml version="1.0" encoding="UTF-8"?>
-<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://www.w3.org/2003/05/soap-envelope
-	http://www.w3.org/2003/05/soap-envelope">
-	<soap:Body>$SOAPBODY$</soap:Body>
-</soap:Envelope>"""
-
-soap = False
-
-def isSoap(document):
-    global soap
-    if document.localName == "Envelope" and\
-            document.namespaceURI in soap_env_NS:
-        soap = True
-        return True
-    else:
-        soap = False
-        return False
-
-class SOAP:
-    """Soap wrapper, used for parsing requests, which are in Soap envelope
-    and creating Soap responses from normal XMLs.
-
-    .. note:: This class is very primitive, it does not support advanced
-        Soap features, like authorization and so on.
-
-    """
-
-    document = None
-    nsIndex = 0
-
-    def __init__(self,document=None):
-
-        if document:
-            if type(input) == type(""):
-                self.document = minidom.parseString(document)
-            else:
-                self.document = document
-
-            self.nsIndex = soap_env_NS.index(document.namespaceURI)
-
-    def getNode(self,namespace,nodeName):
-        """Get XML nod from DOM of specified name and namespace"""
-
-        elements = self.document.getElementsByTagNameNS(namespace, nodeName)
-        if len(elements) > 0:
-            return elements[0]
-        else:
-            return None
-
-    def getResponse(self,document):
-        """Wrap document into soap envelope"""
-        # very primitive, but works
-        document = document.__str__().replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>","")
-        return SOAP_ENVELOPE.replace("$SOAPBODY$",document)
-
-
+"""
+SOAP
+----
+SOAP wrapper 
+"""
+# Author:	Jachym Cepicky
+#        	http://les-ejk.cz
+# License:
+#
+# Web Processing Service implementation
+# Copyright (C) 2006 Jachym Cepicky
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+from xml.dom import minidom
+
+soap_env_NS = ["http://www.w3.org/2003/05/soap-envelope","http://schemas.xmlsoap.org/soap/envelope/"]
+soap_enc_NS = ["http://www.w3.org/2003/05/soap-encoding","http://schemas.xmlsoap.org/soap/encoding/"]
+
+SOAP_ENVELOPE="""<?xml version="1.0" encoding="UTF-8"?>
+<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://www.w3.org/2003/05/soap-envelope
+	http://www.w3.org/2003/05/soap-envelope">
+	<soap:Body>$SOAPBODY$</soap:Body>
+</soap:Envelope>"""
+
+soap = False
+
+def isSoap(document):
+    global soap
+    if document.localName == "Envelope" and\
+            document.namespaceURI in soap_env_NS:
+        soap = True
+        return True
+    else:
+        soap = False
+        return False
+
+class SOAP:
+    """Soap wrapper, used for parsing requests, which are in Soap envelope
+    and creating Soap responses from normal XMLs.
+
+    .. note:: This class is very primitive, it does not support advanced
+        Soap features, like authorization and so on.
+
+    """
+
+    document = None
+    nsIndex = 0
+
+    def __init__(self,document=None):
+
+        if document:
+            if type(input) == type(""):
+                self.document = minidom.parseString(document)
+            else:
+                self.document = document
+            self.nsIndex = soap_env_NS.index(document.namespaceURI)
+
+    def getNode(self,namespace,nodeName):
+        """Get XML nod from DOM of specified name and namespace"""
+
+        elements = self.document.getElementsByTagNameNS(namespace, nodeName)
+        if len(elements) > 0:
+            return elements[0]
+        else:
+            return None
+
+    def getResponse(self,document):
+        """Wrap document into soap envelope"""
+        # very primitive, but works
+        document = document.__str__().replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>","")
+        return SOAP_ENVELOPE.replace("$SOAPBODY$",document)
+



More information about the Pywps-commits mailing list