[Pywps-commits] r879 - in trunk: . pywps pywps/Parser pywps/Process pywps/Wps

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Jan 6 16:35:57 CET 2010


Author: jachym
Date: 2010-01-06 16:35:56 +0100 (Wed, 06 Jan 2010)
New Revision: 879

Added:
   trunk/cgiwps.py
Removed:
   trunk/pywps/Parser/Parser.py
   trunk/pywps/Wps/Response.py
   trunk/wps.py
Modified:
   trunk/pywps/Exceptions.py
   trunk/pywps/Parser/DescribeProcess.py
   trunk/pywps/Parser/Execute.py
   trunk/pywps/Parser/Get.py
   trunk/pywps/Parser/GetCapabilities.py
   trunk/pywps/Parser/Post.py
   trunk/pywps/Parser/__init__.py
   trunk/pywps/Process/Process.py
   trunk/pywps/Process/__init__.py
   trunk/pywps/Wps/DescribeProcess.py
   trunk/pywps/Wps/Execute.py
   trunk/pywps/Wps/GetCapabilities.py
   trunk/pywps/Wps/__init__.py
   trunk/pywps/__init__.py
Log:
another big code restructuralization:
 * Pywps class introduced
 * wps.py renamed to cgiwps.py and rewritten
 * More debugging
 * logFile works


Added: trunk/cgiwps.py
===================================================================
--- trunk/cgiwps.py	2010-01-06 08:06:26 UTC (rev 878)
+++ trunk/cgiwps.py	2010-01-06 15:35:56 UTC (rev 879)
@@ -0,0 +1,100 @@
+#!/usr/bin/env python
+#-*- coding: utf-8 -*-
+"""
+This program is simple implementation of OGC's [http://opengeospatial.org]
+Web Processing Service (OpenGIS(r) Web Processing Service - OGC 05-007r7)
+version 1.0.0 from 2007-06-08
+
+Target of this application is to bring functionality of GIS GRASS
+[http://grass.itc.it] to the World Wide Web - it should work like
+wrapper for modules of this GIS. Though GRASS was at the first place in the
+focus, it is not necessary to use it's modules - you can use any program
+you can script in Python or other language.
+
+The first version was written with support of Deutsche Bundesstiftung
+Umwelt, Osnabrueck, Germany on the spring 2006. SVN server is hosted by
+GDF-Hannover, Hannover, Germany.
+
+Current development is supported mainly by:
+Help Service - Remote Sensing s.r.o
+Cernoleska 1600
+256  01 - Benesov u Prahy
+Czech Republic
+Europe
+
+For setting see comments in 'etc' directory and documentation.
+
+This program is free software, distributed under the terms of GNU General
+Public License as published by the Free Software Foundation version 2 of the
+License.
+
+Enjoy and happy GISing!
+
+$Id: wps.py 871 2009-11-23 14:25:09Z jachym $
+"""
+__version__ = "3.0-svn"
+
+
+# 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.
+#
+# 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 pywps
+from pywps.Exceptions import *
+
+import sys,os, traceback
+
+# get the request method and inputs
+method = os.getenv("REQUEST_METHOD")
+if not method:  # set standard method
+    method = pywps.METHOD_GET
+
+inputQuery = None
+if method == pywps.METHOD_GET:
+    try:
+        inputQuery = os.environ["QUERY_STRING"]
+    except KeyError:
+        # if QUERY_STRING isn't found in env-dictionary, try to read
+        # query from command line:
+        if len(sys.argv)>1:  # any arguments available?
+            inputQuery = sys.argv[1]
+    if not inputQuery:
+        err =  NoApplicableCode("No query string found.")
+        err.promoteException(contentType=True)
+        sys.exit(1)
+else:
+    inputQuery = sys.stdin
+
+
+# create the WPS object
+try:
+    wps = pywps.Pywps(method)
+    if wps.parseRequest(inputQuery):
+        wps.debug(wps.inputs)
+        response = wps.performRequest()
+
+        # request performed, write the response back
+        if response:
+            # print only to standard out
+            if wps.statusFiles == sys.stdout or\
+                sys.stdout in wps.statusFiles:
+                wps.printResponse(wps.statusFiles,wps.parser.isSoap)
+except WPSException,e:
+    traceback.print_exc(file=sys.stderr)
+    e.promoteException(contentType=True)


Property changes on: trunk/cgiwps.py
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/pywps/Exceptions.py
===================================================================
--- trunk/pywps/Exceptions.py	2010-01-06 08:06:26 UTC (rev 878)
+++ trunk/pywps/Exceptions.py	2010-01-06 15:35:56 UTC (rev 879)
@@ -34,7 +34,27 @@
     """
     WPSException should be base class for all exceptions
     """
-    def make_xml(self):
+    code = "NoApplicableCode"
+    value = None
+    locator = None
+
+    def promoteException(self,contentType = False, toFiles=None):
+        """Print this exception text to files
+
+        Parameters:
+        toFiles {List} list of file objects, where to put  this exception
+            text. Default. sys.stdout && sys.stderr
+        """
+
+        if toFiles:
+            for i in toFiles:
+                if contentType: print >>i, "Content-type: text/xml\n"
+                print >>i, self
+        else:
+            if contentType: print >>sys.stdout, "Content-type: text/xml\n"
+            print >>sys.stdout, self
+
+    def _make_xml(self):
         # formulate XML
         self.document = Document()
         self.ExceptionReport = self.document.createElementNS("http://www.opengis.net/ows","ExceptionReport")
@@ -52,38 +72,37 @@
             self.Exception.setAttribute("locator",self.locator)
 
         self.ExceptionReport.appendChild(self.Exception)
-        self.value = None
+        #self.value = None
 
     def __str__(self):
 
-        print  "Content-type: text/xml\n"
         response= self.document.toprettyxml(indent='\t', newl='\n', encoding="utf-8")
         if pywps.Soap.soap == True:
             soapCls = SOAP()
             response = soapCls.getResponse(response)
 
-        sys.stderr.write("PyWPS %s: %s\n" % (self.code, self.locator))
+        sys.stderr.write("PyWPS %s: Locator: %s; Value: %s\n" % (self.code, self.locator, self.value))
 
-        print response
+        return response
 
 class MissingParameterValue(WPSException):
     def __init__(self, value):
         self.code = "MissingParameterValue"
         self.locator = str(value)
-        self.make_xml()
+        self._make_xml()
 
 class InvalidParameterValue(WPSException):
     def __init__(self,value):
         self.code = "InvalidParameterValue"
         self.locator = str(value)
-        self.make_xml()
+        self._make_xml()
 
 class NoApplicableCode(WPSException):
     def __init__(self,value=None):
         WPSException.__init__(self,value)
         self.code = "NoApplicableCode"
-        self.locator = None
-        self.make_xml()
+        self.value = None
+        self._make_xml()
         self.message = value
         if value:
             self.ExceptionText = self.document.createElement("ExceptionText")
@@ -95,7 +114,7 @@
     def __init__(self,value=None):
         self.code = "VersionNegotiationFailed"
         self.locator = None
-        self.make_xml()
+        self._make_xml()
         if value:
             self.ExceptionText = self.document.createElement("ExceptionText")
             self.ExceptionText.appendChild(self.document.createTextNode(value))
@@ -106,25 +125,25 @@
     def __init__(self,value=None):
         self.code = "NotEnoughStorage"
         self.locator = value
-        self.make_xml()
+        self._make_xml()
 
 class StorageNotSupported(WPSException):
     def __init__(self,value=None):
         self.code = "StorageNotSupported"
         self.locator = value
-        self.make_xml()
+        self._make_xml()
 
 class ServerBusy(WPSException):
     def __init__(self,value=None):
         self.code = "ServerBusy"
-        self.locator = str(value)
-        self.make_xml()
+        self.value = value
+        self._make_xml()
 
 class FileSizeExceeded(WPSException):
     def __init__(self,value=None):
         self.code = "FileSizeExceeded"
         self.locator = str(value)
-        self.make_xml()
+        self._make_xml()
 
 class ServerError(WPSException):
     def __init__(self,value=None):
@@ -134,7 +153,8 @@
             self.locator = str(value)
         except:
             self.locator = None
-        self.make_xml()
+        self._make_xml()
         self.ExceptionText = self.document.createElement("ExceptionText")
         self.ExceptionText.appendChild(self.document.createTextNode("General server error"))
         self.Exception.appendChild(self.ExceptionText)
+

Modified: trunk/pywps/Parser/DescribeProcess.py
===================================================================
--- trunk/pywps/Parser/DescribeProcess.py	2010-01-06 08:06:26 UTC (rev 878)
+++ trunk/pywps/Parser/DescribeProcess.py	2010-01-06 15:35:56 UTC (rev 879)
@@ -55,7 +55,7 @@
             identifiers.append(identifierNode.firstChild.nodeValue)
         if len(identifiers) == 0:
             raise self.wps.exceptions.MissingParameterValue("Identifier")
-        self.wps.inputs["identifier"] = identifiers
+        self.inputs["identifier"] = identifiers
 
         #
         # Optional options
@@ -63,7 +63,7 @@
         # language
         self.checkLanguage(firstChild)
 
-        return
+        return self.inputs
 
 class Get(Get):
     """
@@ -85,7 +85,7 @@
 
         # identifier
         if "identifier" in self.unparsedInputs:
-            self.wps.inputs["identifier"] = self.unparsedInputs["identifier"].split(",")
+            self.inputs["identifier"] = self.unparsedInputs["identifier"].split(",")
         else:
             raise self.wps.exceptions.MissingParameterValue("identifier")
 
@@ -94,3 +94,5 @@
 
         # Language
         self.checkLanguage()
+
+        return self.inputs

Modified: trunk/pywps/Parser/Execute.py
===================================================================
--- trunk/pywps/Parser/Execute.py	2010-01-06 08:06:26 UTC (rev 878)
+++ trunk/pywps/Parser/Execute.py	2010-01-06 15:35:56 UTC (rev 879)
@@ -62,7 +62,7 @@
 
         # identifier
         try:
-            self.wps.inputs["identifier"] =\
+            self.inputs["identifier"] =\
             firstChild.getElementsByTagNameNS(self.owsNameSpace,"Identifier")[0].firstChild.nodeValue
         except IndexError:
                 raise self.wps.exceptions.MissingParameterValue("Identifier")
@@ -78,32 +78,32 @@
         try:
             inputsNode = firstChild.getElementsByTagNameNS(
                                             self.nameSpace,"DataInputs")[0]
-            self.wps.inputs["datainputs"] = self.parseDataInputs(inputsNode)
+            self.inputs["datainputs"] = self.parseDataInputs(inputsNode)
         except IndexError:
-            self.wps.inputs["datainputs"] = None
+            self.inputs["datainputs"] = None
 
         # responseForm
         try:
             responseFormNode = \
                 firstChild.getElementsByTagNameNS(self.nameSpace,
                                                         "ResponseForm")[0]
-            self.wps.inputs["responseform"] = self.parseResponseForm(
+            self.inputs["responseform"] = self.parseResponseForm(
                                                         responseFormNode)
         except IndexError:
-            self.wps.inputs["responseform"] = {}
+            self.inputs["responseform"] = {}
 
         # OGC 05-007r7 page 36, Table 49
         # Either responseDocument or rawDataOutput should be specified, not both
-        if self.wps.inputs.has_key('responseform') and \
-           (self.wps.inputs["responseform"].has_key("rawdataoutput") and \
-            self.wps.inputs["responseform"].has_key("responsedocument")):
+        if self.inputs.has_key('responseform') and \
+           (self.inputs["responseform"].has_key("rawdataoutput") and \
+            self.inputs["responseform"].has_key("responsedocument")):
             raise self.wps.exceptions.InvalidParameterValue(
                 "Either responseDocument or rawDataOutput should be specified, but not both")
-        if not self.wps.inputs["responseform"].has_key("rawdataoutput"):
-               self.wps.inputs["responseform"]["rawdataoutput"] = {}
-        if not self.wps.inputs["responseform"].has_key("responsedocument"):
-               self.wps.inputs["responseform"]["responsedocument"] = {}
-        return
+        if not self.inputs["responseform"].has_key("rawdataoutput"):
+               self.inputs["responseform"]["rawdataoutput"] = {}
+        if not self.inputs["responseform"].has_key("responsedocument"):
+               self.inputs["responseform"]["responsedocument"] = {}
+        return self.inputs
 
     def parseResponseForm(self,responseFormNode):
         """ Parse requested response form node """
@@ -429,7 +429,7 @@
 
         # identifier
         if "identifier" in self.unparsedInputs:
-            self.wps.inputs["identifier"] = self.unparsedInputs["identifier"]
+            self.inputs["identifier"] = self.unparsedInputs["identifier"]
         else:
             raise self.wps.exceptions.MissingParameterValue("identifier")
 
@@ -442,63 +442,64 @@
 
         # dataInputs
         try:
-            self.wps.inputs["datainputs"] = self.parseDataInputs(
+            self.inputs["datainputs"] = self.parseDataInputs(
                         self.unparsedInputs["datainputs"])
         except KeyError:
-            self.wps.inputs["datainputs"] = {}
+            self.inputs["datainputs"] = {}
 
         # ResponseForm
 
-        self.wps.inputs["responseform"] = {}
+        self.inputs["responseform"] = {}
 
         # ResponseDocument
         try:
-            self.wps.inputs["responseform"]["responsedocument"] = \
+            self.inputs["responseform"]["responsedocument"] = \
                     {"outputs":  self.parseDataInputs(
                                 self.unparsedInputs["responsedocument"])}
         except KeyError:
-            self.wps.inputs["responseform"]["responsedocument"] = {}
+            self.inputs["responseform"]["responsedocument"] = {}
 
         # RawDataOutput
         try:
-            self.wps.inputs["responseform"]["rawdataoutput"] = \
+            self.inputs["responseform"]["rawdataoutput"] = \
                                     self.parseDataInputs(
                                     self.unparsedInputs["rawdataoutput"])
         except KeyError:
-            self.wps.inputs["responseform"]["rawdataoutput"] = {}
+            self.inputs["responseform"]["rawdataoutput"] = {}
 
         # storeExecuteResponse
         if "storeexecuteresponse" in self.unparsedInputs:
             if self.unparsedInputs["storeexecuteresponse"].lower() ==\
                                                                     "true":
-                self.wps.inputs["responseform"]["responsedocument"]["storeexecuteresponse"] = True
+                self.inputs["responseform"]["responsedocument"]["storeexecuteresponse"] = True
             else:
-                self.wps.inputs["responseform"]["responsedocument"]["storeexecuteresponse"] = False
+                self.inputs["responseform"]["responsedocument"]["storeexecuteresponse"] = False
 
         # lineage
         if "lineage" in self.unparsedInputs:
             if self.unparsedInputs["lineage"].lower() == "true":
-                self.wps.inputs["responseform"]["responsedocument"]["lineage"]=\
+                self.inputs["responseform"]["responsedocument"]["lineage"]=\
                                                                         True
             else:
-                self.wps.inputs["responseform"]["responsedocument"]["lineage"]=\
+                self.inputs["responseform"]["responsedocument"]["lineage"]=\
                                                                        False
 
         # status
         if "status" in self.unparsedInputs:
             if self.unparsedInputs["status"].lower() == "true":
-                self.wps.inputs["responseform"]["responsedocument"]["status"]=\
+                self.inputs["responseform"]["responsedocument"]["status"]=\
                                                                         True
             else:
-                self.wps.inputs["responseform"]["responsedocument"]["status"]=\
+                self.inputs["responseform"]["responsedocument"]["status"]=\
                                                                       False
 
         # OGC 05-007r7 page 36, Table 49
         # Either responseDocument or rawDataOutput should be specified, not both
-        if len(self.wps.inputs["responseform"]["rawdataoutput"])>0 and \
-            len(self.wps.inputs["responseform"]["responsedocument"])>0:
+        if len(self.inputs["responseform"]["rawdataoutput"])>0 and \
+            len(self.inputs["responseform"]["responsedocument"])>0:
             raise self.wps.exceptions.InvalidParameterValue(
                 "Either responseDocument or rawDataOutput should be specified, but not both")
+        return self.inputs
 
     def parseDataInputs(self,dataInputs):
         """Parse DataInputs parameter

Modified: trunk/pywps/Parser/Get.py
===================================================================
--- trunk/pywps/Parser/Get.py	2010-01-06 08:06:26 UTC (rev 878)
+++ trunk/pywps/Parser/Get.py	2010-01-06 15:35:56 UTC (rev 879)
@@ -30,7 +30,7 @@
 
 import types
 from string import split
-from pywps.Parser.Parser import Parser
+from pywps.Parser import Parser
 from pywps.Process.Lang import Lang
 import urllib
 
@@ -66,7 +66,7 @@
             # KVP in request string (OWS_1-1-0, p.75, sect. 11.2):
             if not feature == '':
                 if feature.lower() == "wsdl":
-                    self.wps.inputs["wsdl"] = True
+                    self.inputs["wsdl"] = True
                     break
                 else:
                     try:
@@ -83,7 +83,7 @@
                 self.unparsedInputs[key.lower()] = value[:maxInputLength]
 
 
-        if not self.wps.inputs.has_key("wsdl"):
+        if not self.inputs.has_key("wsdl"):
             # check service name
             service = self.checkService()
 
@@ -93,7 +93,7 @@
             # parse the request
             self.requestParser.parse(self.unparsedInputs)
 
-        return
+        return self.inputs
 
     def checkRequestType(self):
         """Find requested request type and import given request parser."""
@@ -107,17 +107,17 @@
            self.GET_CAPABILITIES:
             import GetCapabilities
             self.requestParser = GetCapabilities.Get(self.wps)
-            self.wps.inputs["request"] = self.GET_CAPABILITIES
+            self.inputs["request"] = self.GET_CAPABILITIES
         elif self.unparsedInputs["request"].lower() ==\
            self.DESCRIBE_PROCESS:
             import DescribeProcess
             self.requestParser = DescribeProcess.Get(self.wps)
-            self.wps.inputs["request"] = self.DESCRIBE_PROCESS
+            self.inputs["request"] = self.DESCRIBE_PROCESS
         elif self.unparsedInputs["request"].lower() ==\
            self.EXECUTE:
             import Execute
             self.requestParser = Execute.Get(self.wps)
-            self.wps.inputs["request"] = self.EXECUTE
+            self.inputs["request"] = self.EXECUTE
         else:
             raise self.wps.exceptions.InvalidParameterValue("request")
 
@@ -130,14 +130,14 @@
         if "service" in self.unparsedInputs:
             value=self.unparsedInputs["service"].upper()
             if value == "WSDL":
-                self.wps.inputs["service"] = "WSDL"
+                self.inputs["service"] = "WSDL"
             elif value != "WPS":
                 raise self.wps.exceptions.InvalidParameterValue("service")
             else:
-                self.wps.inputs["service"] = "WPS"
+                self.inputs["service"] = "WPS"
         else:
             raise self.wps.exceptions.MissingParameterValue("service")
-        return self.wps.inputs["service"]
+        return self.inputs["service"]
 
     def checkLanguage(self):
         """ Check optional language parameter.  """
@@ -147,9 +147,9 @@
             if value not in self.wps.languages:
                 raise self.wps.exceptions.InvalidParameterValue("language")
             else:
-                self.wps.inputs["language"] = value
+                self.inputs["language"] = value
         else:
-            self.wps.inputs["language"] = self.wps.defaultLanguage
+            self.inputs["language"] = self.wps.defaultLanguage
 
     def checkVersion(self):
         """ Check mandatory version parameter.  """
@@ -161,6 +161,6 @@
                     'The requested version "' + value + \
                     '" is not supported by this server.')
             else:
-                self.wps.inputs["version"] = value
+                self.inputs["version"] = value
         else:
             raise self.wps.exceptions.MissingParameterValue("version")

Modified: trunk/pywps/Parser/GetCapabilities.py
===================================================================
--- trunk/pywps/Parser/GetCapabilities.py	2010-01-06 08:06:26 UTC (rev 878)
+++ trunk/pywps/Parser/GetCapabilities.py	2010-01-06 15:35:56 UTC (rev 879)
@@ -61,11 +61,11 @@
                 versions.append(versionNode.firstChild.nodeValue)
         if len(versions) == 0:
             versions = self.wps.versions
-        self.wps.inputs["acceptversions"] = versions
-        for version in self.wps.inputs["acceptversions"]:
+        self.inputs["acceptversions"] = versions
+        for version in self.inputs["acceptversions"]:
             if version in self.wps.versions:
-                self.wps.inputs["version"]=version
-        if not "version" in self.wps.inputs:
+                self.inputs["version"]=version
+        if not "version" in self.inputs:
             raise self.wps.exceptions.VersionNegotiationFailed(
                                 "There's no version in AcceptVersions parameter " +
                                 "that is supported by this server.")
@@ -73,7 +73,7 @@
         # language
         self.checkLanguage(firstChild)
 
-        return
+        return self.inputs
 
 class Get(Get):
     """ Parses input request obtained via HTTP GET encoding.  """
@@ -93,14 +93,14 @@
 
         # AcceptVersions
         try:
-            self.wps.inputs["acceptversions"] = \
+            self.inputs["acceptversions"] = \
                                self.unparsedInputs["acceptversions"].split(",")
         except KeyError,e:
-            self.wps.inputs["acceptversions"] = self.wps.versions
-        for version in self.wps.inputs["acceptversions"]:
+            self.inputs["acceptversions"] = self.wps.versions
+        for version in self.inputs["acceptversions"]:
             if version in self.wps.versions:
-                self.wps.inputs["version"]=version
-        if not "version" in self.wps.inputs:
+                self.inputs["version"]=version
+        if not "version" in self.inputs:
             raise self.wps.exceptions.VersionNegotiationFailed(
                                 "There's no version in AcceptVersions parameter " +
                                 "that is supported by this server.")
@@ -108,3 +108,4 @@
         # Language
         self.checkLanguage()
 
+        return self.inputs

Deleted: trunk/pywps/Parser/Parser.py
===================================================================
--- trunk/pywps/Parser/Parser.py	2010-01-06 08:06:26 UTC (rev 878)
+++ trunk/pywps/Parser/Parser.py	2010-01-06 15:35:56 UTC (rev 879)
@@ -1,29 +0,0 @@
-# Author:	Jachym Cepicky
-#        	http://les-ejk.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.
-#
-# 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
-
-class Parser:
-    """Parent class for all request parsers."""
-
-    wps = None
-    isSoap = False
-
-    def __init__(self,wps):
-        self.wps = wps
-

Modified: trunk/pywps/Parser/Post.py
===================================================================
--- trunk/pywps/Parser/Post.py	2010-01-06 08:06:26 UTC (rev 878)
+++ trunk/pywps/Parser/Post.py	2010-01-06 15:35:56 UTC (rev 879)
@@ -21,7 +21,7 @@
 import types,sys
 import xml
 from xml.dom.minidom import parseString
-from pywps.Parser.Parser import Parser
+from pywps.Parser import Parser
 from pywps.Process.Lang import Lang
 from pywps import Soap 
 
@@ -80,6 +80,8 @@
         # parse the document
         self.requestParser.parse(self.document)
 
+        return self.inputs
+
     def checkService(self, node):
         """ Check mandatory service name parameter.  """
 
@@ -90,7 +92,7 @@
             if value != "WPS":
                 raise self.wps.exceptions.InvalidParameterValue("service")
             else:
-                self.wps.inputs["service"] = "WPS"
+                self.inputs["service"] = "WPS"
         else:
             raise self.wps.exceptions.MissingParameterValue("service")
 
@@ -102,9 +104,9 @@
             if value not in self.wps.languages:
                 raise self.wps.exceptions.InvalidParameterValue("language")
             else:
-                self.wps.inputs["language"] = value
+                self.inputs["language"] = value
         else:
-            self.wps.inputs["language"] = self.wps.defaultLanguage
+            self.inputs["language"] = self.wps.defaultLanguage
 
     def checkVersion(self, node):
         """ Check optional language parameter.  """
@@ -116,7 +118,7 @@
                     'The requested version "' + value + \
                     '" is not supported by this server.')
             else:
-                self.wps.inputs["version"] = value
+                self.inputs["version"] = value
         else:
             raise self.wps.exceptions.MissingParameterValue("version")
 
@@ -128,15 +130,15 @@
         if firstTagName.find(self.GET_CAPABILITIES) > -1:
             import GetCapabilities
             self.requestParser = GetCapabilities.Post(self.wps)
-            self.wps.inputs["request"] = "getcapabilities"
+            self.inputs["request"] = "getcapabilities"
         elif firstTagName.find(self.DESCRIBE_PROCESS) > -1:
             import DescribeProcess
             self.requestParser = DescribeProcess.Post(self.wps)
-            self.wps.inputs["request"] = "describeprocess"
+            self.inputs["request"] = "describeprocess"
         elif firstTagName.find(self.EXECUTE) > -1:
             import Execute
             self.requestParser = Execute.Post(self.wps)
-            self.wps.inputs["request"] = "execute"
+            self.inputs["request"] = "execute"
         else:
             raise self.wps.Exceptions.InvalidParameterValue("request")
 

Modified: trunk/pywps/Parser/__init__.py
===================================================================
--- trunk/pywps/Parser/__init__.py	2010-01-06 08:06:26 UTC (rev 878)
+++ trunk/pywps/Parser/__init__.py	2010-01-06 15:35:56 UTC (rev 879)
@@ -5,11 +5,43 @@
 
 $Id$
 """
+
+# Author:	Jachym Cepicky
+#        	http://les-ejk.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.
+#
+# 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
+
 __all__ = [
-        "Parser",
         "Get",
         "Post",
         "GetCapabilities",
         "DescribeProcess",
         "Execute"
         ]
+
+
+class Parser:
+    """Parent class for all request parsers."""
+
+    wps = None
+    isSoap = False
+    inputs = {}
+
+    def __init__(self,wps):
+        self.wps = wps
+

Modified: trunk/pywps/Process/Process.py
===================================================================
--- trunk/pywps/Process/Process.py	2010-01-06 08:06:26 UTC (rev 878)
+++ trunk/pywps/Process/Process.py	2010-01-06 15:35:56 UTC (rev 879)
@@ -1,540 +1,7 @@
-# Author:	Jachym Cepicky
-#        	http://les-ejk.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.
-#
-# 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 InAndOutputs
-import Lang
-
-import subprocess
-import time
-import types
-import sys,os
-import traceback
-
-class Status:
-    """
-    Status object for each process
-
-    Attributes:
-    creationTime time.time()
-    code {String} "processstarted", "processfailed" or anything else
-    percentCompleted {Float} how far the calculation is
-    value {String} message string to the client
-    """
-    creationTime = time.time()
-    code = None
-    percentCompleted = 0
-    code = None
-    value = None
-
-    def set(self, msg="",percentDone=0, propagate=True):
-        """ Set status message
-
-        Parameters:
-        msg {String} message for the client
-        percentDone {Float} percent > 0
-        propagate {Boolean} call onStatusChanged method
-        """
-        self.code = "processstarted"
-        if (type(percentDone) == types.StringType):
-            self.percentCompleted += int(percentDone)
-        else:
-            self.percentCompleted = percentDone
-
-        if not msg:
-            msg = "True"
-
-        self.value = msg
-
-        if propagate:
-            self.onStatusChanged()
-
-    def onStatusChanged(self):
-        """
-        To be redefined by other methods
-        """
-        pass
-
-    def setProcessStatus(self,code,value):
-        """
-        Sets current status of the process. Calls onStatusChanged method
-
-        Parameters:
-        code {String} one of "processaccepted" "processstarted"
-                    "processsucceeded" "processpaused" "processfailed"
-        value {String} additional message
-        """
-
-        self.value = value
-        self.code = code.lower()
-
-        if self.code != "processfailed":
-            self.onStatusChanged()
-        return
-
-
-class WPSProcess:
-    """Base class for any PyWPS Process"""
-    identifier = None
-    version = None
-    metadata = None
-    title = None
-    abstract = None
-    wsdl  = None
-    profile = None
-    storeSupported = None
-    statusSupported = None
-    debug = None
-    status = None
-    inputs = None
-    outputs = None
-    lang = None
-    grassLocation = None
-    grassMapset = None
-    logFile = None
-
-    def __init__(self, identifier, title = None, abstract=None,
-            metadata=[],profile=[], version=None,
-            statusSupported=True, storeSupported=False, grassLocation=None,
-            logFile = sys.stderr):
-        """Process initialization. All parameters can be set lately
-
-        Mandatory parameters:
-        identifier {String} process identifier
-        title {String} process title
-
-        Optional parameters:
-        abstract {String} process description
-                default: None
-        metadata List of additional metadata.  See
-                    http://www.opengeospatial.org/standards/common, table 32 on page 65
-                E.g. ["foo":"bar"]
-                default: None
-        profile [URN]
-                default: None
-        version {String} process version
-                default: None
-        statusSupported {Boolean} this process can be run asynchronously
-                default: True
-        storeSupported {Boolean} outputs from this process can be stored
-                for later download
-                default: True
-        grassLocation {String} or {Boolean} name of GRASS Location within
-                "gisdbase" directory (from pywps.cfg configuration file).
-                If set to True, temporary GRASS Location will be created
-                and grass environment will be started. If None or False, no
-                GRASS environment will be started.
-                default: None
-        """
-
-
-        self.identifier = identifier
-        self.version = version
-        self.metadata = metadata
-        self.title = title
-        self.abstract = abstract
-        self.wsdl  = None
-        self.profile = profile
-        # "true" or "True" -> True
-        if type(storeSupported) == type(""):
-            if storeSupported.find("t") == 0 or\
-                storeSupported.find("T") == 0:
-                storeSupported = True
-            else:
-                storeSupported = False
-        self.storeSupported = storeSupported
-        if type(statusSupported) == type(""):
-            if statusSupported.find("t") == 0 or\
-                statusSupported.find("T") == 0:
-                statusSupported = True
-            else:
-                statusSupported = False
-        self.statusSupported = statusSupported
-
-	# status not supported on windows
-	if os.name == "nt":
-		self.statusSupported = False
-
-        self.debug = False
-
-        self.status = Status()
-        self.inputs = {}
-        self.outputs = {}
-
-        self.lang = Lang.Lang()
-
-        self.grassLocation = grassLocation
-
-    def initProcess(self, title = None, abstract=None,
-            metadata=[],profile=[], version=None,
-            statusSupported=True, storeSupported=False, grassLocation=None):
-        """Can be used for later process re-initialization
-
-        For parameters, see __init__ method options.  """
-
-        self.title = title
-        self.abstract = abstract
-        self.metadata = metadata
-        self.profile = profile
-        self.version = version
-        if type(storeSupported) == type(""):
-            if storeSupported.find("t") == 0 or\
-                storeSupported.find("T") == 0:
-                storeSupported = True
-            else:
-                storeSupported = False
-        self.storeSupported = storeSupported
-        if type(statusSupported) == type(""):
-            if statusSupported.find("t") == 0 or\
-                statusSupported.find("T") == 0:
-                statusSupported = True
-            else:
-                statusSupported = False
-        self.statusSupported = statusSupported
-
-        self.grassLocation = grassLocation
-
-    def addLiteralInput(self, identifier, title, abstract=None,
-            uoms=(), minOccurs=1, maxOccurs=1,
-            allowedValues=("*"), type=types.IntType ,
-            default=None, metadata= []):
-        """
-        Add new input item of type LiteralValue to this process
-
-        Mandatory parameters:
-        identifier {String} input identifier
-        title {String} input title
-
-        Optional parameters:
-        abstract {String} input description. Default: None
-                    default: None
-        uoms List of {String} value units
-                    default: ()
-        minOccurs {Integer} minimum number of occurrences.
-                    default: 1
-        maxOccurs {Integer} maximum number of occurrences.
-                    default: 1
-        allowedValues  List of {String} or {List} list of allowed values,
-                    which can be used with this input. You can set interval
-                    using list with two items, like:
-
-                    (1,2,3,(5,9),10,"a",("d","g"))
-
-                    This will produce allowed values 1,2,3,10, "a" and
-                    any value between 5 and 9 or "d" and "g".
-
-                    If "*" is used, it means "any value"
-                    default: ("*")
-        type {types.TypeType} value type, e.g. Integer, String, etc. you
-                    can uses the "types" module of python.
-                    default: types.IntType
-        default {Any} default value.
-                    default: None
-        metadata List of {Dict} Additional metadata. E.g. {"foo":"bar"}
-                    default: None
-        """
-
-        self.inputs[identifier] = InAndOutputs.LiteralInput(identifier=identifier,
-                title=title, abstract=abstract, metadata=metadata,
-                minOccurs=minOccurs,maxOccurs=maxOccurs,
-                dataType=type, uoms=uoms, values=allowedValues,
-                default=default)
-
-        return self.inputs[identifier]
-
-    def addComplexInput(self,identifier,title,abstract=None,
-                metadata=[],minOccurs=1,maxOccurs=1,
-                formats=[{"mimeType":"text/xml"}],maxmegabites=5):
-        """Add complex input to this process
-
-        Mandatory parameters:
-        identifier {String} input identifier
-        title {String} input title
-
-        Optional parameters:
-        abstract {String} input description.
-                default: None
-        metadata List of {Dict} {key:value} pairs.
-                default: None
-        minOccurs {Integer} minimum number of occurrences.
-                default: 1
-        maxOccurs {Integer} maximum number of occurrences.
-                default: 1
-        formats List of {Dict} according to table 23 (page 25). E.g.
-                    [
-                        {"mimeType": "image/tiff"},
-                        {
-                            "mimeType": "text/xml",
-                            "encoding": "utf-8",
-                            "schema":"http://foo/bar"
-                        }
-                    ]
-                default: [{"mimeType":"text/xml"}]
-        maxmegabites {Float} Maximum input file size. Can not be bigger, as
-                defined in global configuration file.
-                default: 5
-        """
-
-
-        self.inputs[identifier] = InAndOutputs.ComplexInput(identifier=identifier,
-                title=title,abstract=abstract,
-                metadata=metadata,minOccurs=minOccurs,maxOccurs=maxOccurs,
-                formats=formats, maxmegabites=maxmegabites)
-
-        return self.inputs[identifier]
-
-
-    def addBBoxInput(self,identifier,title,abstract=None,
-                metadata=[],minOccurs=1,maxOccurs=1,
-                crss=["EPSG:4326"]):
-        """Add BoundingBox input
-
-        Mandatory parameters:
-        identifier {String} input identifier
-        title {String} input title
-
-        Optional parameters:
-        abstract {String} input description.
-                default: None
-        metadata List of {Dict} {key:value} pairs.
-                default: None
-        minOccurs {Integer} minimum number of occurrences.
-                default: 1
-        maxOccurs {Integer} maximum number of occurrences.
-                default: 1
-        crss List of {String} supported coordinate systems.
-                default: ["EPSG:4326"]
-        """
-        self.inputs[identifier] = InAndOutputs.BoundingBoxInput(identifier,
-                title, abstract=abstract, metadata=metadata,
-                minOccurs=minOccurs, maxOccurs=maxOccurs, crss=crss)
-
-        return self.inputs[identifier]
-
-    # --------------------------------------------------------------------
-
-    def addComplexOutput(self,identifier,title,abstract=None,
-            metadata=[],formats=[{"mimeType":"text/xml"}],
-            useMapscript=False):
-        """Add complex output to this process
-
-        Mandatory parameters:
-        identifier {String} output identifier
-        title {String} output title
-
-        Optional parameters:
-        metadata List of {Dict} {key:value} pairs.
-                default: None
-        formats List of {Dict} according to table 23 (page 25). E.g.
-                    [
-                        {"mimeType": "image/tiff"},
-                        {
-                            "mimeType": "text/xml",
-                            "encoding": "utf-8",
-                            "schema":"http://foo/bar"
-                        }
-                    ]
-                default: [{"mimeType":"text/xml"}]
-        """
-
-        self.outputs[identifier] = InAndOutputs.ComplexOutput(identifier=identifier,
-                title=title,abstract=abstract, metadata=metadata,
-                formats=formats,useMapscript = useMapscript)
-
-        return self.outputs[identifier]
-
-    def addLiteralOutput(self, identifier, title, abstract=None,
-            uoms=(), type=types.IntType, default=None):
-        """
-        Add new output item of type LiteralValue to this process
-
-        Mandatory parameters:
-        identifier {String} input identifier
-        title {String} input title
-
-        Optional parameters:
-        abstract {String} input description. 
-                    default: None
-        uoms List of {String} value units
-                    default: ()
-        type {types.TypeType} value type, e.g. Integer, String, etc. you
-                    can uses the "types" module of python.
-                    default: types.IntType
-        default {Any} default value.
-                    default: None
-        """
-
-        self.outputs[identifier] = InAndOutputs.LiteralOutput(identifier=identifier,
-                title=title, abstract=abstract, dataType=type, uoms=uoms)
-
-        return self.outputs[identifier]
-
-    def addBBoxOutput(self, identifier, title, abstract=None,
-            crs="EPSG:4326", dimensions=2):
-        """Add new output item of type BoundingBoxValue to this process
-
-        Mandatory parameters:
-        identifier {String} input identifier
-        title {String} input title
-
-        Optional parameters:
-        abstract {String} input description.
-                default: None
-        crss List of {String} supported coordinate systems.
-                default: ["EPSG:4326"]
-        dimensions {Integer} number of dimensions
-                default: 2
-        """
-
-        self.outputs[identifier] = InAndOutputs.BoundingBoxOutput(identifier=identifier,
-                title=title, abstract=abstract, crss=[crs], dimensions=dimensions)
-
-        return self.outputs[identifier]
-
-    # --------------------------------------------------------------------
-    def cmd(self,cmd,stdin=None,stdout=True):
-        """Runs GRASS command, fetches all GRASS_MESSAGE and
-        GRASS_PERCENT messages and sets self.status according to them, so
-        the client application can track the progress information, when
-        running with Status=True
-
-        This module is supposed to be used instead of 'os.system()', while
-        running GRASS modules
-
-        Parameters:
-        cmd {String} the command
-        stdin {String} string to be send into the command via standard in
-        stdout {Boolean}  give stdout and stderror from the command back
-
-        Returns:
-        {String} stdoutdata
-
-        Example Usage:
-            self.cmd("r.los in=elevation.dem out=los coord=1000,1000")
-
-            self.cmd("v.net.path network afcol=forward abcol=backward \
-            out=mypath nlayer=1","1 9 12")
-
-            self.cmd("d.mon start=PNG",stdout=False)
-            """
-
-        # splitting the command, if not already done
-        if (type(cmd) == types.StringType):
-            cmd = cmd.strip().split()
-
-        if stdin:
-            idx = stdin.find("\n")
-            if 0 < idx <= 60:
-                stdinOut = " "+stdin[:idx]
-            else:
-                stdinOut = " "+stdin[:60]
-        else:
-            stdinOut = ""
-
-        self.message("PyWPS Cmd: %s\n" % (" ".join(cmd)+stdinOut))
-
-        try:
-            subprocessstdin = None
-            if stdin:
-                subprocessstdin = subprocess.PIPE
-
-            subprocessstdout = None
-            subprocessstderr = None
-            if stdout:
-                subprocessstdout = subprocess.PIPE
-                subprocessstderr = subprocess.PIPE
-
-            p = subprocess.Popen(cmd,
-                stdin=subprocessstdin, stdout=subprocessstdout,
-                stderr=subprocessstderr)
-        except Exception,e :
-            traceback.print_exc(file=sys.stderr)
-            self.failed = True
-            raise Exception("Could not perform command [%s]: %s" % (cmd,e))
-
-        (stdout, stderr) = p.communicate(stdin)
-
-        retcode = p.wait()
-
-        if retcode != 0:
-           self.status.setProcessStatus("processFailed", True)
-           self.message("PyWPS stderr: %s\n" % (stderr),True)
-           raise Exception("PyWPS could not perform command [%s]:\n%s" % (cmd,stderr))
-
-        return stdout
-
-    def message(self,msg,force=False):
-        """Print some message to standard error
-
-        Parameters:
-        msg {String} print this string to standard error
-        force {Boolean} if self.debug or force == True, the message will be
-                printed. nothing happen otherwise.
-        """
-
-        if self.debug or force and self.logFile:
-            if type(self.logFile) == type(""):
-                try:
-                    f = open(self.logFile,"w")
-                    f.write(msg)
-                    f.close()
-                except:
-                    print >>sys.stderr, "PyWPS WARNING: Could not write to logfile [%s]" % self.logFile
-            else:
-                self.logFile.write(msg)
-        return
-
-    def getInput(self,identifier):
-        """Get input defined by identifier
-
-        Returns: None or Input
-        """
-        try:
-            return self.inputs[identifier]
-        except:
-            return None
-
-    def getInputValue(self,identifier):
-        """Get input value according to identifier
-
-        Returns: None or self.inputs[identifier].value
-        """
-
-        try:
-            return self.inputs[identifier].getValue()
-        except:
-            return None
-
-    def setOutputValue(self,identifier,value):
-        """Set output value
-
-        Returns: None
-        """
-        try:
-            return self.outputs[identifier].setValue(value)
-        except:
-            return None
-
-    def i18n(self,key):
-        """Give back translation of defined key
-
-        Returns: {String} translated string
-        """
-        return self.lang.get(key)
-
+from pywps.Process import WPSProcess
+import sys
+print >>sys.stderr, """PyWPS Warning: Usage of"""
+print >>sys.stderr, """PyWPS Warning:       from pywps.Process.Process import WPSProcess"""
+print >>sys.stderr, """PyWPS Warning: is deprecated. Use """
+print >>sys.stderr, """PyWPS Warning:       from pywps.Process import WPSProcess"""
+print >>sys.stderr, """PyWPS Warning: instead!"""

Modified: trunk/pywps/Process/__init__.py
===================================================================
--- trunk/pywps/Process/__init__.py	2010-01-06 08:06:26 UTC (rev 878)
+++ trunk/pywps/Process/__init__.py	2010-01-06 15:35:56 UTC (rev 879)
@@ -1,2 +1,542 @@
-"""Process package with necessary classes"""
-__all__ = ["Process", "Lang","InAndOutputs" ]
+# Author:	Jachym Cepicky
+#        	http://les-ejk.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.
+#
+# 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
+
+__all__ = ["Lang","InAndOutputs" ]
+
+import InAndOutputs
+import Lang
+
+import subprocess
+import time
+import types
+import sys,os
+import traceback
+
+class Status:
+    """
+    Status object for each process
+
+    Attributes:
+    creationTime time.time()
+    code {String} "processstarted", "processfailed" or anything else
+    percentCompleted {Float} how far the calculation is
+    value {String} message string to the client
+    """
+    creationTime = time.time()
+    code = None
+    percentCompleted = 0
+    code = None
+    value = None
+
+    def set(self, msg="",percentDone=0, propagate=True):
+        """ Set status message
+
+        Parameters:
+        msg {String} message for the client
+        percentDone {Float} percent > 0
+        propagate {Boolean} call onStatusChanged method
+        """
+        self.code = "processstarted"
+        if (type(percentDone) == types.StringType):
+            self.percentCompleted += int(percentDone)
+        else:
+            self.percentCompleted = percentDone
+
+        if not msg:
+            msg = "True"
+
+        self.value = msg
+
+        if propagate:
+            self.onStatusChanged()
+
+    def onStatusChanged(self):
+        """
+        To be redefined by other methods
+        """
+        pass
+
+    def setProcessStatus(self,code,value):
+        """
+        Sets current status of the process. Calls onStatusChanged method
+
+        Parameters:
+        code {String} one of "processaccepted" "processstarted"
+                    "processsucceeded" "processpaused" "processfailed"
+        value {String} additional message
+        """
+
+        self.value = value
+        self.code = code.lower()
+
+        if self.code != "processfailed":
+            self.onStatusChanged()
+        return
+
+
+class WPSProcess:
+    """Base class for any PyWPS Process"""
+    identifier = None
+    version = None
+    metadata = None
+    title = None
+    abstract = None
+    wsdl  = None
+    profile = None
+    storeSupported = None
+    statusSupported = None
+    debug = None
+    status = None
+    inputs = None
+    outputs = None
+    lang = None
+    grassLocation = None
+    grassMapset = None
+    logFile = None
+
+    def __init__(self, identifier, title = None, abstract=None,
+            metadata=[],profile=[], version=None,
+            statusSupported=True, storeSupported=False, grassLocation=None,
+            logFile = sys.stderr):
+        """Process initialization. All parameters can be set lately
+
+        Mandatory parameters:
+        identifier {String} process identifier
+        title {String} process title
+
+        Optional parameters:
+        abstract {String} process description
+                default: None
+        metadata List of additional metadata.  See
+                    http://www.opengeospatial.org/standards/common, table 32 on page 65
+                E.g. ["foo":"bar"]
+                default: None
+        profile [URN]
+                default: None
+        version {String} process version
+                default: None
+        statusSupported {Boolean} this process can be run asynchronously
+                default: True
+        storeSupported {Boolean} outputs from this process can be stored
+                for later download
+                default: True
+        grassLocation {String} or {Boolean} name of GRASS Location within
+                "gisdbase" directory (from pywps.cfg configuration file).
+                If set to True, temporary GRASS Location will be created
+                and grass environment will be started. If None or False, no
+                GRASS environment will be started.
+                default: None
+        """
+
+
+        self.identifier = identifier
+        self.version = version
+        self.metadata = metadata
+        self.title = title
+        self.abstract = abstract
+        self.wsdl  = None
+        self.profile = profile
+        # "true" or "True" -> True
+        if type(storeSupported) == type(""):
+            if storeSupported.find("t") == 0 or\
+                storeSupported.find("T") == 0:
+                storeSupported = True
+            else:
+                storeSupported = False
+        self.storeSupported = storeSupported
+        if type(statusSupported) == type(""):
+            if statusSupported.find("t") == 0 or\
+                statusSupported.find("T") == 0:
+                statusSupported = True
+            else:
+                statusSupported = False
+        self.statusSupported = statusSupported
+
+	# status not supported on windows
+	if os.name == "nt":
+		self.statusSupported = False
+
+        self.debug = False
+
+        self.status = Status()
+        self.inputs = {}
+        self.outputs = {}
+
+        self.lang = Lang.Lang()
+
+        self.grassLocation = grassLocation
+
+    def initProcess(self, title = None, abstract=None,
+            metadata=[],profile=[], version=None,
+            statusSupported=True, storeSupported=False, grassLocation=None):
+        """Can be used for later process re-initialization
+
+        For parameters, see __init__ method options.  """
+
+        self.title = title
+        self.abstract = abstract
+        self.metadata = metadata
+        self.profile = profile
+        self.version = version
+        if type(storeSupported) == type(""):
+            if storeSupported.find("t") == 0 or\
+                storeSupported.find("T") == 0:
+                storeSupported = True
+            else:
+                storeSupported = False
+        self.storeSupported = storeSupported
+        if type(statusSupported) == type(""):
+            if statusSupported.find("t") == 0 or\
+                statusSupported.find("T") == 0:
+                statusSupported = True
+            else:
+                statusSupported = False
+        self.statusSupported = statusSupported
+
+        self.grassLocation = grassLocation
+
+    def addLiteralInput(self, identifier, title, abstract=None,
+            uoms=(), minOccurs=1, maxOccurs=1,
+            allowedValues=("*"), type=types.IntType ,
+            default=None, metadata= []):
+        """
+        Add new input item of type LiteralValue to this process
+
+        Mandatory parameters:
+        identifier {String} input identifier
+        title {String} input title
+
+        Optional parameters:
+        abstract {String} input description. Default: None
+                    default: None
+        uoms List of {String} value units
+                    default: ()
+        minOccurs {Integer} minimum number of occurrences.
+                    default: 1
+        maxOccurs {Integer} maximum number of occurrences.
+                    default: 1
+        allowedValues  List of {String} or {List} list of allowed values,
+                    which can be used with this input. You can set interval
+                    using list with two items, like:
+
+                    (1,2,3,(5,9),10,"a",("d","g"))
+
+                    This will produce allowed values 1,2,3,10, "a" and
+                    any value between 5 and 9 or "d" and "g".
+
+                    If "*" is used, it means "any value"
+                    default: ("*")
+        type {types.TypeType} value type, e.g. Integer, String, etc. you
+                    can uses the "types" module of python.
+                    default: types.IntType
+        default {Any} default value.
+                    default: None
+        metadata List of {Dict} Additional metadata. E.g. {"foo":"bar"}
+                    default: None
+        """
+
+        self.inputs[identifier] = InAndOutputs.LiteralInput(identifier=identifier,
+                title=title, abstract=abstract, metadata=metadata,
+                minOccurs=minOccurs,maxOccurs=maxOccurs,
+                dataType=type, uoms=uoms, values=allowedValues,
+                default=default)
+
+        return self.inputs[identifier]
+
+    def addComplexInput(self,identifier,title,abstract=None,
+                metadata=[],minOccurs=1,maxOccurs=1,
+                formats=[{"mimeType":"text/xml"}],maxmegabites=5):
+        """Add complex input to this process
+
+        Mandatory parameters:
+        identifier {String} input identifier
+        title {String} input title
+
+        Optional parameters:
+        abstract {String} input description.
+                default: None
+        metadata List of {Dict} {key:value} pairs.
+                default: None
+        minOccurs {Integer} minimum number of occurrences.
+                default: 1
+        maxOccurs {Integer} maximum number of occurrences.
+                default: 1
+        formats List of {Dict} according to table 23 (page 25). E.g.
+                    [
+                        {"mimeType": "image/tiff"},
+                        {
+                            "mimeType": "text/xml",
+                            "encoding": "utf-8",
+                            "schema":"http://foo/bar"
+                        }
+                    ]
+                default: [{"mimeType":"text/xml"}]
+        maxmegabites {Float} Maximum input file size. Can not be bigger, as
+                defined in global configuration file.
+                default: 5
+        """
+
+
+        self.inputs[identifier] = InAndOutputs.ComplexInput(identifier=identifier,
+                title=title,abstract=abstract,
+                metadata=metadata,minOccurs=minOccurs,maxOccurs=maxOccurs,
+                formats=formats, maxmegabites=maxmegabites)
+
+        return self.inputs[identifier]
+
+
+    def addBBoxInput(self,identifier,title,abstract=None,
+                metadata=[],minOccurs=1,maxOccurs=1,
+                crss=["EPSG:4326"]):
+        """Add BoundingBox input
+
+        Mandatory parameters:
+        identifier {String} input identifier
+        title {String} input title
+
+        Optional parameters:
+        abstract {String} input description.
+                default: None
+        metadata List of {Dict} {key:value} pairs.
+                default: None
+        minOccurs {Integer} minimum number of occurrences.
+                default: 1
+        maxOccurs {Integer} maximum number of occurrences.
+                default: 1
+        crss List of {String} supported coordinate systems.
+                default: ["EPSG:4326"]
+        """
+        self.inputs[identifier] = InAndOutputs.BoundingBoxInput(identifier,
+                title, abstract=abstract, metadata=metadata,
+                minOccurs=minOccurs, maxOccurs=maxOccurs, crss=crss)
+
+        return self.inputs[identifier]
+
+    # --------------------------------------------------------------------
+
+    def addComplexOutput(self,identifier,title,abstract=None,
+            metadata=[],formats=[{"mimeType":"text/xml"}],
+            useMapscript=False):
+        """Add complex output to this process
+
+        Mandatory parameters:
+        identifier {String} output identifier
+        title {String} output title
+
+        Optional parameters:
+        metadata List of {Dict} {key:value} pairs.
+                default: None
+        formats List of {Dict} according to table 23 (page 25). E.g.
+                    [
+                        {"mimeType": "image/tiff"},
+                        {
+                            "mimeType": "text/xml",
+                            "encoding": "utf-8",
+                            "schema":"http://foo/bar"
+                        }
+                    ]
+                default: [{"mimeType":"text/xml"}]
+        """
+
+        self.outputs[identifier] = InAndOutputs.ComplexOutput(identifier=identifier,
+                title=title,abstract=abstract, metadata=metadata,
+                formats=formats,useMapscript = useMapscript)
+
+        return self.outputs[identifier]
+
+    def addLiteralOutput(self, identifier, title, abstract=None,
+            uoms=(), type=types.IntType, default=None):
+        """
+        Add new output item of type LiteralValue to this process
+
+        Mandatory parameters:
+        identifier {String} input identifier
+        title {String} input title
+
+        Optional parameters:
+        abstract {String} input description. 
+                    default: None
+        uoms List of {String} value units
+                    default: ()
+        type {types.TypeType} value type, e.g. Integer, String, etc. you
+                    can uses the "types" module of python.
+                    default: types.IntType
+        default {Any} default value.
+                    default: None
+        """
+
+        self.outputs[identifier] = InAndOutputs.LiteralOutput(identifier=identifier,
+                title=title, abstract=abstract, dataType=type, uoms=uoms)
+
+        return self.outputs[identifier]
+
+    def addBBoxOutput(self, identifier, title, abstract=None,
+            crs="EPSG:4326", dimensions=2):
+        """Add new output item of type BoundingBoxValue to this process
+
+        Mandatory parameters:
+        identifier {String} input identifier
+        title {String} input title
+
+        Optional parameters:
+        abstract {String} input description.
+                default: None
+        crss List of {String} supported coordinate systems.
+                default: ["EPSG:4326"]
+        dimensions {Integer} number of dimensions
+                default: 2
+        """
+
+        self.outputs[identifier] = InAndOutputs.BoundingBoxOutput(identifier=identifier,
+                title=title, abstract=abstract, crss=[crs], dimensions=dimensions)
+
+        return self.outputs[identifier]
+
+    # --------------------------------------------------------------------
+    def cmd(self,cmd,stdin=None,stdout=True):
+        """Runs GRASS command, fetches all GRASS_MESSAGE and
+        GRASS_PERCENT messages and sets self.status according to them, so
+        the client application can track the progress information, when
+        running with Status=True
+
+        This module is supposed to be used instead of 'os.system()', while
+        running GRASS modules
+
+        Parameters:
+        cmd {String} the command
+        stdin {String} string to be send into the command via standard in
+        stdout {Boolean}  give stdout and stderror from the command back
+
+        Returns:
+        {String} stdoutdata
+
+        Example Usage:
+            self.cmd("r.los in=elevation.dem out=los coord=1000,1000")
+
+            self.cmd("v.net.path network afcol=forward abcol=backward \
+            out=mypath nlayer=1","1 9 12")
+
+            self.cmd("d.mon start=PNG",stdout=False)
+            """
+
+        # splitting the command, if not already done
+        if (type(cmd) == types.StringType):
+            cmd = cmd.strip().split()
+
+        if stdin:
+            idx = stdin.find("\n")
+            if 0 < idx <= 60:
+                stdinOut = " "+stdin[:idx]
+            else:
+                stdinOut = " "+stdin[:60]
+        else:
+            stdinOut = ""
+
+        self.message("PyWPS Cmd: %s\n" % (" ".join(cmd)+stdinOut))
+
+        try:
+            subprocessstdin = None
+            if stdin:
+                subprocessstdin = subprocess.PIPE
+
+            subprocessstdout = None
+            subprocessstderr = None
+            if stdout:
+                subprocessstdout = subprocess.PIPE
+                subprocessstderr = subprocess.PIPE
+
+            p = subprocess.Popen(cmd,
+                stdin=subprocessstdin, stdout=subprocessstdout,
+                stderr=subprocessstderr)
+        except Exception,e :
+            traceback.print_exc(file=sys.stderr)
+            self.failed = True
+            raise Exception("Could not perform command [%s]: %s" % (cmd,e))
+
+        (stdout, stderr) = p.communicate(stdin)
+
+        retcode = p.wait()
+
+        if retcode != 0:
+           self.status.setProcessStatus("processFailed", True)
+           self.message("PyWPS stderr: %s\n" % (stderr),True)
+           raise Exception("PyWPS could not perform command [%s]:\n%s" % (cmd,stderr))
+
+        return stdout
+
+    def message(self,msg,force=False):
+        """Print some message to standard error
+
+        Parameters:
+        msg {String} print this string to standard error
+        force {Boolean} if self.debug or force == True, the message will be
+                printed. nothing happen otherwise.
+        """
+
+        if self.debug or force and self.logFile:
+            if type(self.logFile) == type(""):
+                try:
+                    f = open(self.logFile,"w")
+                    f.write(msg)
+                    f.close()
+                except:
+                    print >>sys.stderr, "PyWPS WARNING: Could not write to logfile [%s]" % self.logFile
+            else:
+                self.logFile.write(msg)
+        return
+
+    def getInput(self,identifier):
+        """Get input defined by identifier
+
+        Returns: None or Input
+        """
+        try:
+            return self.inputs[identifier]
+        except:
+            return None
+
+    def getInputValue(self,identifier):
+        """Get input value according to identifier
+
+        Returns: None or self.inputs[identifier].value
+        """
+
+        try:
+            return self.inputs[identifier].getValue()
+        except:
+            return None
+
+    def setOutputValue(self,identifier,value):
+        """Set output value
+
+        Returns: None
+        """
+        try:
+            return self.outputs[identifier].setValue(value)
+        except:
+            return None
+
+    def i18n(self,key):
+        """Give back translation of defined key
+
+        Returns: {String} translated string
+        """
+        return self.lang.get(key)
+

Modified: trunk/pywps/Wps/DescribeProcess.py
===================================================================
--- trunk/pywps/Wps/DescribeProcess.py	2010-01-06 08:06:26 UTC (rev 878)
+++ trunk/pywps/Wps/DescribeProcess.py	2010-01-06 15:35:56 UTC (rev 879)
@@ -23,11 +23,11 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
-from Response import Response
+from pywps.Wps import Request
 from htmltmpl import TemplateError
-import os,types
+import os,types,traceback
 
-class DescribeProcess(Response):
+class DescribeProcess(Request):
     """
     Parses input request obtained via HTTP POST encoding - should be XML
     file.
@@ -39,13 +39,13 @@
            self
            wps   - parent WPS instance
         """
-        Response.__init__(self,wps)
+        Request.__init__(self,wps)
 
         try:
             self.template = self.templateManager.prepare(self.templateFile)
         except TemplateError,e:
             self.cleanEnv()
-            raise self.wps.exceptions.NoApplicableCode(e.__str__())
+            raise wps.exceptions.NoApplicableCode(e.__str__())
 
         #
         # HEAD
@@ -127,6 +127,7 @@
                 processData["dataoutputslen"] = len(processData["Dataoutputs"])
 
             except Exception, e:
+                traceback.print_exc(file=self.wps.logFile)
                 processData["processok"] = 0
                 processData["process"] = processName
                 processData["exception"] = e

Modified: trunk/pywps/Wps/Execute.py
===================================================================
--- trunk/pywps/Wps/Execute.py	2010-01-06 08:06:26 UTC (rev 878)
+++ trunk/pywps/Wps/Execute.py	2010-01-06 15:35:56 UTC (rev 879)
@@ -23,7 +23,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
-from Response import Response
+from pywps.Wps import Request
 from htmltmpl import TemplateError
 import time,os,sys,tempfile,re,types, ConfigParser, base64, traceback
 from shutil import copyfile as COPY
@@ -34,7 +34,7 @@
 except:
     pass
 
-class Execute(Response):
+class Execute(Request):
     """
     This class performs the Execute request of WPS specification
     """
@@ -78,7 +78,6 @@
     grass = None
 
     rawDataOutput = None
-    logFile = None
 
     mapObj = None
     mapFileName = None
@@ -89,19 +88,18 @@
         wps   - parent WPS instance
         """
 
-        Response.__init__(self,wps)
+        Request.__init__(self,wps)
 
         self.wps = wps
         self.process = None
         try:
             self.template = self.templateManager.prepare(self.templateFile)
         except TemplateError,e:
-            traceback.print_exc(file=sys.stderr)
+            traceback.print_exc(file=self.wps.logFile)
             self.cleanEnv()
             raise self.wps.exceptions.NoApplicableCode(e.__str__())
 
         # initialization
-        self.setLogFile()
         self.statusTime = time.time()
         self.pid = os.getpid()
         self.status = None
@@ -130,7 +128,7 @@
                 try:
                     self.statusFiles.append(open(self.statusFileName,"w"))
                 except Exception, e:
-                    traceback.print_exc(file=sys.stderr)
+                    traceback.print_exc(file=self.wps.logFile)
                     self.cleanEnv()
                     raise self.wps.exceptions.NoApplicableCode(e.__str__())
                 self.storeRequired = True
@@ -212,7 +210,7 @@
                         pass
 
                 except OSError, e:
-                    traceback.print_exc(file=sys.stderr)
+                    traceback.print_exc(file=self.wps.logFile)
                     raise self.wps.exceptions.NoApplicableCode("Fork failed: %d (%s)\n" % (e.errno, e.strerror) )
 
             # this is child process, parent is already gone away
@@ -239,6 +237,7 @@
 
         except self.wps.exceptions.WPSException,e:
             # set status to failed
+            traceback.print_exc(file=self.wps.logFile)
             self.promoteStatus(self.failed,
                      statusMessage=e.value,
                      exceptioncode=e.code,
@@ -246,7 +245,7 @@
         except Exception,e:
 
             # set status to failed
-            traceback.print_exc(file=sys.stderr)
+            traceback.print_exc(file=self.wps.logFile)
             self.promoteStatus(self.failed,
                     statusMessage=str(e),
                     exceptioncode="NoApplicableCode")
@@ -290,6 +289,7 @@
 
 
         except self.wps.exceptions.WPSException,e:
+            traceback.print_exc(file=self.wps.logFile)
             # set status to failed
             self.promoteStatus(self.failed,
                     statusMessage=e.value,
@@ -300,7 +300,7 @@
 
         except Exception,e:
             # set status to failed
-            traceback.print_exc(file=sys.stderr)
+            traceback.print_exc(file=self.wps.logFile)
             self.promoteStatus(self.failed,
                     statusMessage=str(e),
                     exceptioncode="NoApplicableCode")
@@ -309,7 +309,7 @@
 
         # print status
         if self.storeRequired and self.statusRequired:
-            self.printResponse(self.statusFiles)
+            self.wps.printResponse(self.statusFiles,response=self.response)
 
         # remove all temporary files
         self.cleanEnv()
@@ -330,7 +330,7 @@
 
             except Exception, e:
                 self.cleanEnv()
-                traceback.print_exc(file=sys.stderr)
+                traceback.print_exc(file=self.wps.logFile)
                 raise self.wps.exceptions.NoApplicableCode(
                 "Could not import process [%s]: %s" %\
                         (self.wps.inputs["identifier"], e))
@@ -345,7 +345,7 @@
         self.process.wps = self.wps
         self.process.status.onStatusChanged = self.onStatusChanged
         self.process.debug = self.wps.getConfigValue("server","debug")
-        self.process.logFile = self.logFile
+        self.process.logFile = self.wps.logFile
 
     def consolidateInputs(self):
         """ Donwload and control input data, defined by the client """
@@ -460,7 +460,7 @@
             # execute
             processError = self.process.execute()
             if processError:
-                traceback.print_exc(file=sys.stderr)
+                traceback.print_exc(file=self.wps.logFile)
                 raise self.wps.exceptions.NoApplicableCode(
                         "Failed to execute WPS process [%s]: %s" %\
                                 (self.process.identifier,processError))
@@ -475,7 +475,7 @@
             raise e
 
         except Exception,e:
-            traceback.print_exc(file=sys.stderr)
+            traceback.print_exc(file=self.wps.logFile)
             raise self.wps.exceptions.NoApplicableCode(
                     "Failed to execute WPS process [%s]: %s" %\
                             (self.process.identifier,e))
@@ -570,12 +570,14 @@
                                    self.status == self.accepted or
                                    #self.status == self.succeeded or
                                    self.status == self.failed):
-            self.printResponse(self.statusFiles)
+            self.wps.printResponse(self.statusFiles, response=self.response, )
         
         if self.status == self.started:
-            print >>sys.stderr, "PyWPS Status [%s][%.1f]: %s" % (self.status,float(self.percent),self.statusMessage)
+            self.wps.debug("%s" % self.statusMessage,
+                    code = "PyWPS Status [%s][%.1f]: "% (self.status,float(self.percent)))
         else:
-            print >>sys.stderr, "PyWPS Status [%s]: %s" % (self.status,self.statusMessage)
+            self.wps.debug("%s" % self.statusMessage,
+                        code="PyWPS Status [%s]"%self.status )
 
 
     def lineageInputs(self):
@@ -756,7 +758,7 @@
 
             except Exception,e:
                 self.cleanEnv()
-                traceback.print_exc(file=sys.stderr)
+                traceback.print_exc(file=self.wps.logFile)
                 raise self.wps.exceptions.NoApplicableCode(
                         "Process executed. Failed to build final response for output [%s]: %s" % (identifier,e))
         self.templateProcessor.set("Outputs",templateOutputs)
@@ -979,7 +981,7 @@
         """
 
         self.promoteStatus(self.process.status.code,
-                statusMessage=self.process.status.value,
+                statusMessage="%s %s"%(self.process.status.code,self.process.status.value),
                 percent=self.process.status.percentCompleted)
 
     def initEnv(self):
@@ -1000,7 +1002,7 @@
 
         if pyWPSDirs >= maxOperations and\
             maxOperations != 0:
-            raise self.wps.exceptions.ServerBusy()
+            raise self.wps.exceptions.ServerBusy(value="Maximal number of permitted operations exceeded")
 
         # create temp dir
         self.workingDir = tempfile.mkdtemp(prefix="pywps", dir=tempPath)
@@ -1024,7 +1026,7 @@
                     raise Exception("Location [%s] does not exist" % self.process.grassLocation)
         except Exception,e:
             self.cleanEnv()
-            traceback.print_exc(file=sys.stderr)
+            traceback.print_exc(file=self.wps.logFile)
             raise self.wps.exceptions.NoApplicableCode("Could not init GRASS: %s" % e)
 
         return
@@ -1079,29 +1081,7 @@
             print f.read()
             f.close()
 
-    def setLogFile(self):
-        """Set self.logFile to sys.stderr or something else
-        """
 
-        # logfile
-        self.logFile = sys.stderr
-        try:
-            self.logFile = self.wps.getConfigValue("server","logFile")
-            if self.logFile:
-                se = open(self.logFile, 'a+', 0)
-                os.dup2(se.fileno(), sys.stderr.fileno())
-            else:
-                self.logFile = sys.stderr
-        except ConfigParser.NoOptionError,e:
-            pass
-        except IOError,e:
-            traceback.print_exc(file=sys.stderr)
-            raise self.wps.exceptions.NoApplicableCode("Logfile IOError: %s" % e.__str__())
-        except Exception, e:
-            traceback.print_exc(file=sys.stderr)
-            raise self.wps.exceptions.NoApplicableCode("Logfile error: %s" % e.__str__())
-
-
     def _initMapscript(self):
         """Create self.mapObj"""
 

Modified: trunk/pywps/Wps/GetCapabilities.py
===================================================================
--- trunk/pywps/Wps/GetCapabilities.py	2010-01-06 08:06:26 UTC (rev 878)
+++ trunk/pywps/Wps/GetCapabilities.py	2010-01-06 15:35:56 UTC (rev 879)
@@ -23,11 +23,11 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
-from Response import Response
+from pywps.Wps import Request
 from htmltmpl import TemplateError
-import types
+import types, traceback
 
-class GetCapabilities(Response):
+class GetCapabilities(Request):
     """
     Parses input request obtained via HTTP POST encoding - should be XML
     file.
@@ -40,7 +40,7 @@
            wps   - parent WPS instance
         """
         try:
-            Response.__init__(self,wps)
+            Request.__init__(self,wps)
         except Exception, e:
             self.cleanEnv()
             rep = None
@@ -48,7 +48,7 @@
                 rep = e.message
             except:
                 rep = e.__str__()
-            raise self.wps.exceptions.NoApplicableCode(rep)
+            raise wps.exceptions.NoApplicableCode(rep)
 
         try:
             self.template = self.templateManager.prepare(self.templateFile)
@@ -202,11 +202,13 @@
                         processData["wsdl"] = process.wsdl
 
                 except Exception, e:
+                    traceback.print_exc(file=self.wps.logFile)
                     processData["processok"] = 0
                     processData["process"] = processName
                     processData["exception"] = e
                 processesData.append(processData)
         except Exception,e:
+            traceback.print_exc(file=self.wps.logFile)
             raise self.wps.exceptions.NoApplicableCode("Could not import processes: %s " % (e))
         self.templateProcessor.set("Processes",processesData)
 

Deleted: trunk/pywps/Wps/Response.py
===================================================================
--- trunk/pywps/Wps/Response.py	2010-01-06 08:06:26 UTC (rev 878)
+++ trunk/pywps/Wps/Response.py	2010-01-06 15:35:56 UTC (rev 879)
@@ -1,194 +0,0 @@
-"""
-Request handler - prototype class
-"""
-# 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
-# make sure, that the package python-htmltmpl is installed on your system!
-from htmltmpl import TemplateManager, TemplateProcessor
-import os
-from sys import stdout as STDOUT
-import types
-from pywps import Templates
-from pywps import Soap
-import re
-
-class Response:
-    response = None # Output document
-    respSize = None # Size of the ouput document
-    wps = None # Parent WPS object
-    templateManager = None # HTML TemplateManager
-    templateProcessor = TemplateProcessor(html_escape=0) # HTML TemplateProcessor
-    template = None # HTML Template
-    templateFile = None # File with template
-    processDir = None # Directory with processes
-    statusFiles = STDOUT
-    emptyParamRegex = re.compile('( \w+="")|( \w+="None")')
-    templateVersionDirectory = None # directory with templates for specified version
-    precompile = 1
-    stdOutClosed = False
-
-    def __init__(self,wps):
-        self.wps = wps
-
-        self.templateVersionDirectory = self.wps.inputs["version"].replace(".","_")
-
-	if os.name == "nt" or os.name == "java":
-		self.precompile = 0
-
-        self.templateManager = TemplateManager(precompile = self.precompile,
-            debug = self.wps.config.getboolean("server","debug"))
-
-        if self.wps.inputs.has_key("request"):
-            if self.wps.inputs["request"] == "getcapabilities":
-                self.templateFile = os.path.join(
-                                    os.path.join(Templates.__path__)[0],
-                                    self.templateVersionDirectory,
-                                        "GetCapabilities.tmpl")
-            elif self.wps.inputs["request"] == "describeprocess":
-                self.templateFile = os.path.join(
-                                    os.path.join(Templates.__path__)[0],
-                                    self.templateVersionDirectory,
-                                        "DescribeProcess.tmpl")
-            elif self.wps.inputs["request"] == "execute":
-                self.templateFile = os.path.join(
-                                    os.path.join(Templates.__path__)[0],
-                                    self.templateVersionDirectory,
-                                        "Execute.tmpl")
-        elif self.wps.inputs.has_key("wsdl"):
-            self.templateFile = os.path.join(
-                                os.path.join(Templates.__path__)[0],
-                                self.templateVersionDirectory,
-                                    "Wsdl.tmpl")
-
-        self.processDir = os.getenv("PYWPS_PROCESSES")
-        if self.processDir:
-            self.wps.debug("PYWPS_PROCESSES set from environment variable to %s" %self.processDir)
-        else:
-            self.wps.debug("PYWPS_PROCESSES environment variable not set or empty.  Trying to find something in the configuration file")
-            try:
-                self.processDir = self.wps.getConfigValue("server", "processesPath")
-                self.wps.debug("PYWPS_PROCESSES: set from configuration file to [%s]" %self.processDir)
-            except: 
-                self.wps.debug("'processesPath' not found in the 'server' section of pywps configuration file")
-
-        if self.processDir:
-            import sys
-            if self.processDir[-1] == os.path.sep:
-                self.processDir = self.processDir[:-1]
-
-            try:
-                sys.path.insert(0,os.path.split(self.processDir)[0])
-                processes = __import__(os.path.split(self.processDir)[-1])
-                self.processes = processes
-            except ImportError,e:
-                raise self.wps.exceptions.NoApplicableCode("Could not import processes from the dir [%s]: %s! __init__.py file missing?" % (self.processDir,e))
-
-            sys.path.append(self.processDir)
-        else:
-            self.wps.debug("Importing the processes from default (pywps/processes) location")
-            try:
-                import pywps
-            except ImportError,e:
-                raise self.wps.exceptions.NoApplicableCode("Could not import pywps module: %s" % (e))
-            try:
-                from pywps import processes
-                self.wps.debug("PYWPS_PROCESSES: %s" %os.path.abspath(pywps.processes.__path__[-1]))
-            except Exception,e:
-                raise self.wps.exceptions.NoApplicableCode("Could not import pywps.processes module: %s" % (e))
-            self.processes = pywps.processes
-
-    def getDataTypeReference(self,inoutput):
-        """
-        Returns data type reference according to W3C
-        """
-
-        dataType = {"type": None, "reference": None}
-        if inoutput.dataType == types.StringType:
-            dataType["type"] = "string"
-            dataType["reference"] = "http://www.w3.org/TR/xmlschema-2/#string"
-        elif inoutput.dataType == types.FloatType:
-            dataType["type"] = "float"
-            dataType["reference"] = "http://www.w3.org/TR/xmlschema-2/#float"
-        elif inoutput.dataType == types.IntType:
-            dataType["type"] = "integer"
-            dataType["reference"] = "http://www.w3.org/TR/xmlschema-2/#integer"
-        elif inoutput.dataType == types.BooleanType:
-            dataType["type"] = "boolean"
-            dataType["reference"] = "http://www.w3.org/TR/xmlschema-2/#boolean"
-        else:
-            # TODO To be continued...
-            dataType["type"] = "string"
-            dataType["reference"] = "http://www.w3.org/TR/xmlschema-2/#string"
-            pass
-
-        return dataType
-
-    def printResponse(self,fileDes,isSoap=False):
-        """
-        print response to file descriptor file descriptor
-        can be of type list or file
-
-        Parameters:
-            fileDes - file descriptor, where to print the result
-            isSoap - Boolean, if the response should be printed in the SOAP
-                    envelope or no
-        """
-
-        if type(fileDes) != type([]):
-            fileDes = [fileDes]
-
-        response = self.response
-        if isSoap:
-            soap = Soap.SOAP()
-            response = soap.getResponse(response)
-
-
-        for f in fileDes:
-
-	    if f == STDOUT and self.stdOutClosed == True:
-		    continue
-
-            if f == STDOUT:
-                print "Content-Type: text/xml"
-                #print "Content-Length: %d" % len(self.response)
-                print ""
-
-            # open file
-            if f != STDOUT and f.closed:
-                f = open(f.name,"w")
-
-            # '""' and '"None"'s will be removed
-            f.write(re.sub(self.emptyParamRegex,"",response))
-            f.flush()
-
-            if (f != STDOUT):
-                f.close()
-
-	    # remove stdout from fileDes
-	    else: 
-		self.stdOutClosed = True
-
-    def cleanEnv(self):
-        """Clean possible temporary files etc. created by this request
-        type"""

Modified: trunk/pywps/Wps/__init__.py
===================================================================
--- trunk/pywps/Wps/__init__.py	2010-01-06 08:06:26 UTC (rev 878)
+++ trunk/pywps/Wps/__init__.py	2010-01-06 15:35:56 UTC (rev 879)
@@ -1,7 +1,159 @@
-"""
-Classes for WPS request types:
-    * GetCapabilities
-    * DescribeProcess
-    * Execute
-"""
-__all__ = ["GetCapabilities","DescribeProcess","Execute"]
+# 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
+__all__ = ["GetCapabilities","DescribeProcess","Execute","Wsdl"]
+
+import xml.dom.minidom
+# make sure, that the package python-htmltmpl is installed on your system!
+from htmltmpl import TemplateManager, TemplateProcessor
+import os
+from sys import stdout as STDOUT
+from sys import stderr as STDERR
+import types
+from pywps import Templates
+from pywps import Soap
+
+class Request:
+    response = None # Output document
+    respSize = None # Size of the ouput document
+    wps = None # Parent WPS object
+    templateManager = None # HTML TemplateManager
+    templateProcessor = TemplateProcessor(html_escape=0) # HTML TemplateProcessor
+    template = None # HTML Template
+    templateFile = None # File with template
+    processDir = None # Directory with processes
+    templateVersionDirectory = None # directory with templates for specified version
+    precompile = 1
+    stdOutClosed = False
+
+    def __init__(self,wps):
+        self.wps = wps
+
+        self.templateVersionDirectory = self.wps.inputs["version"].replace(".","_")
+
+	if os.name == "nt" or os.name == "java":
+		self.precompile = 0
+
+        self.templateManager = TemplateManager(precompile = self.precompile,
+            debug = self.wps.config.getboolean("server","debug"))
+
+        if self.wps.inputs.has_key("request"):
+            if self.wps.inputs["request"] == "getcapabilities":
+                self.templateFile = os.path.join(
+                                    os.path.join(Templates.__path__)[0],
+                                    self.templateVersionDirectory,
+                                        "GetCapabilities.tmpl")
+            elif self.wps.inputs["request"] == "describeprocess":
+                self.templateFile = os.path.join(
+                                    os.path.join(Templates.__path__)[0],
+                                    self.templateVersionDirectory,
+                                        "DescribeProcess.tmpl")
+            elif self.wps.inputs["request"] == "execute":
+                self.templateFile = os.path.join(
+                                    os.path.join(Templates.__path__)[0],
+                                    self.templateVersionDirectory,
+                                        "Execute.tmpl")
+        elif self.wps.inputs.has_key("wsdl"):
+            self.templateFile = os.path.join(
+                                os.path.join(Templates.__path__)[0],
+                                self.templateVersionDirectory,
+                                    "Wsdl.tmpl")
+
+        self.processDir = os.getenv("PYWPS_PROCESSES")
+        if self.processDir:
+            self.wps.debug("PYWPS_PROCESSES set from environment variable to %s" %self.processDir)
+        else:
+            self.wps.debug("PYWPS_PROCESSES environment variable not set or empty.  Trying to find something in the configuration file")
+            try:
+                self.processDir = self.wps.getConfigValue("server", "processesPath")
+                self.wps.debug("PYWPS_PROCESSES: set from configuration file to [%s]" %self.processDir)
+            except: 
+                self.wps.debug("'processesPath' not found in the 'server' section of pywps configuration file")
+
+        if self.processDir:
+            import sys
+            if self.processDir[-1] == os.path.sep:
+                self.processDir = self.processDir[:-1]
+
+            try:
+                sys.path.insert(0,os.path.split(self.processDir)[0])
+                processes = __import__(os.path.split(self.processDir)[-1])
+                self.processes = processes
+            except ImportError,e:
+                traceback.print_exc(file=self.logFile)
+                raise self.wps.exceptions.NoApplicableCode("Could not import processes from the dir [%s]: %s! __init__.py file missing?" % (self.processDir,e))
+
+            sys.path.append(self.processDir)
+        else:
+            self.wps.debug("Importing the processes from default (pywps/processes) location")
+            try:
+                import pywps
+            except ImportError,e:
+                traceback.print_exc(file=self.logFile)
+                raise self.wps.exceptions.NoApplicableCode("Could not import pywps module: %s" % (e))
+            try:
+                from pywps import processes
+                self.wps.debug("PYWPS_PROCESSES: %s" %os.path.abspath(pywps.processes.__path__[-1]))
+            except Exception,e:
+                traceback.print_exc(file=self.logFile)
+                raise self.wps.exceptions.NoApplicableCode("Could not import pywps.processes module: %s" % (e))
+            self.processes = pywps.processes
+
+        # check, if all required processes are available
+        if self.wps.inputs.has_key("identifier"):
+            if type(self.wps.inputs["identifier"]) == type(""):
+                if not self.wps.inputs["identifier"] in self.processes.__all__:
+                    raise self.wps.exceptions.InvalidParameterValue(prc)
+            else:
+                for prc in self.wps.inputs["identifier"]:
+                    if not prc in self.processes.__all__:
+                        raise self.wps.exceptions.InvalidParameterValue(prc)
+
+    def getDataTypeReference(self,inoutput):
+        """
+        Returns data type reference according to W3C
+        """
+
+        dataType = {"type": None, "reference": None}
+        if inoutput.dataType == types.StringType:
+            dataType["type"] = "string"
+            dataType["reference"] = "http://www.w3.org/TR/xmlschema-2/#string"
+        elif inoutput.dataType == types.FloatType:
+            dataType["type"] = "float"
+            dataType["reference"] = "http://www.w3.org/TR/xmlschema-2/#float"
+        elif inoutput.dataType == types.IntType:
+            dataType["type"] = "integer"
+            dataType["reference"] = "http://www.w3.org/TR/xmlschema-2/#integer"
+        elif inoutput.dataType == types.BooleanType:
+            dataType["type"] = "boolean"
+            dataType["reference"] = "http://www.w3.org/TR/xmlschema-2/#boolean"
+        else:
+            # TODO To be continued...
+            dataType["type"] = "string"
+            dataType["reference"] = "http://www.w3.org/TR/xmlschema-2/#string"
+            pass
+
+        return dataType
+
+    def cleanEnv(self):
+        """Clean possible temporary files etc. created by this request
+        type"""
+

Modified: trunk/pywps/__init__.py
===================================================================
--- trunk/pywps/__init__.py	2010-01-06 08:06:26 UTC (rev 878)
+++ trunk/pywps/__init__.py	2010-01-06 15:35:56 UTC (rev 879)
@@ -5,7 +5,332 @@
 
 Here is also the default package with WPS Processes.
 
+This program is free software, distributed under the terms of GNU General
+Public License as published by the Free Software Foundation version 2 of the
+License.
+
+
 $Id$
 """
 
 __all__ = [ "Parser","processes", "Process", "Exceptions", "Wps", "Templates"]
+
+
+# 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.
+#
+# 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 pywps
+import Parser
+import Exceptions
+import Wps
+from Exceptions import *
+
+import sys, os, ConfigParser, urllib, re, traceback
+from sys import stdout as STDOUT
+from sys import stderr as STDERR
+
+# global variables
+METHOD_GET="GET"
+METHOD_POST="POST"
+OWS_NAMESPACE = "http://www.opengis.net/ows/1.1"
+WPS_NAMESPACE = "http://www.opengis.net/wps/1.0.0"
+XLINK_NAMESPACE = "http://www.w3.org/1999/xlink"
+EMPTYPARAMREGEX = re.compile('( \w+="")|( \w+="None")')
+
+
+class Pywps:
+    """This is main PyWPS Class, which parses the request, performs the
+    desired operation and writes required response back.
+    """
+
+    method  =""                      # HTTP POST or GET
+    parser = None
+    config = None  # Configuration
+    workingDir = None # this working directory
+
+    exceptions = pywps.Exceptions
+    statusFiles = STDOUT
+    stdOutClosed = False
+
+    inputs = {} # parsed input values
+    request = None # object with getcapabilities/describeprocess/execute
+                   # class
+    parser = None # pywps.Parser Get or Post
+
+    defaultLanguage = "eng"
+    languages = [defaultLanguage]
+    defaultVersion = "1.0.0"
+    versions=[defaultVersion]
+    logFile = STDERR
+
+    def __init__(self, method, configFiles=None):
+        """Class constructor
+
+        Will load configuration files, parse the input parameters and
+        perform the request.
+
+        Parameters:
+        configFiles {List} list of configuration files. Ignore, if you want
+            to use standard files location
+
+        """
+
+        # get settings
+        self._loadConfiguration(configFiles)
+        self._setLogFile()
+
+        # set default language
+        self.languages = self.getConfigValue("wps","lang").split(",")
+        self.defaultLanguage = self.languages[0]
+
+        # set default version
+        self.versions=self.getConfigValue("wps","version").split(",")
+        self.defaultVersion = self.versions[0]
+
+        # find out the request method
+        self.method = method
+        if not self.method:  # set standard method
+            self.method = METHOD_GET
+
+
+    def parseRequest(self,queryStringObject):
+        """
+        Parameters:
+        queryStringObject {String|file} string or file object with the
+        request
+
+        Return:
+        {Object} inputs
+        """
+
+        # decide, which method to use
+        # HTTP GET vs. HTTP POST
+        if self.method == METHOD_GET:
+            from Parser.Get import Get
+            self.parser = Get(self)
+        else:
+            from pywps.Parser.Post import Post
+            self.parser = Post(self)
+
+        self.inputs = self.parser.parse(queryStringObject)
+        return self.inputs
+
+    def _loadConfiguration(self, cfgfiles=None):
+        """Load PyWPS configuration from configuration files.
+        The later overwrites configuration from the first
+
+        Parameters:
+        cfgfiles {List} array of file names, where to get configuration from.
+
+        """
+
+        if cfgfiles == None:
+            cfgfiles = self.getDefaultConfigFilesLocation()
+
+        if type(cfgfiles) != type(()):
+            cfgfiles = (cfgfiles)
+
+        self.config = ConfigParser.ConfigParser()
+        self.config.read(cfgfiles)
+
+    def getDefaultConfigFilesLocation(self):
+        """
+        Get the locations of the standard configuration files. This are
+
+        Unix/Linux:
+        pywps/default.cfg
+        /etc/pywps.cfg
+        pywps/etc/pywps.cfg
+        $HOME/.pywps.cfg
+
+        Windows:
+        pywps\\default.cfg
+        pywps\\etc\\default.cfg
+        
+        Both:
+        $PYWPS_CFG environment variable
+
+        Returns:
+        {List} configuration files
+        """
+
+        # configuration file as environment variable
+        if os.getenv("PYWPS_CFG"):
+
+            # Windows or Unix
+            if sys.platform == 'win32':
+                self.workingDir = os.path.abspath(os.path.join(os.getcwd(), os.path.dirname(sys.argv[0])))
+                cfgfiles = (os.path.join(self.workingDir,"pywps","default.cfg"),
+                        os.getenv("PYWPS_CFG"))
+            else:
+                cfgfiles = (os.path.join(pywps.__path__[0],"default.cfg"),
+                        os.getenv("PYWPS_CFG"))
+
+        # try to eastimate the default location
+        else:
+            # Windows or Unix
+            if sys.platform == 'win32':
+                self.workingDir = os.path.abspath(os.path.join(os.getcwd(), os.path.dirname(sys.argv[0])))
+                cfgfiles = (os.path.join(self.workingDir,"pywps","default.cfg"),
+                        os.path.join(self.workingDir, "pywps","etc","pywps.cfg"))
+            else:
+                homePath = os.getenv("HOME")
+                if homePath:
+                    cfgfiles = (os.path.join(pywps.__path__[0],"default.cfg"),
+                            os.path.join(pywps.__path__[0],"etc", "pywps.cfg"), "/etc/pywps.cfg",
+                        os.path.join(os.getenv("HOME"),".pywps.cfg" ))
+                else: 
+                    cfgfiles = (os.path.join(pywps.__path__[0],"default.cfg"),
+                            os.path.join(pywps.__path__[0],"etc",
+                                "pywps.cfg"), "/etc/pywps.cfg")
+        return cfgfiles
+
+
+    def performRequest(self,inputs = None):
+        """Performs the desired WSP Request.
+        
+        Parameters:
+        inputs {Object} idealy self.inputs (Default)
+        """
+
+        if inputs == None:
+            inputs = self.inputs
+
+        # the modules are imported first, when the request type is known
+        if inputs.has_key("request"):
+            if inputs["request"]  == "getcapabilities":
+                from pywps.Wps.GetCapabilities import GetCapabilities
+                self.request = GetCapabilities(self)
+            elif inputs["request"]  == "describeprocess":
+                from pywps.Wps.DescribeProcess import DescribeProcess
+                self.request = DescribeProcess(self)
+            elif inputs["request"]  == "execute":
+                from pywps.Wps.Execute import Execute
+                self.request = Execute(self)
+        elif inputs.has_key("wsdl"):
+            inputs["version"]="1.0.0"
+            from pywps.Wps.Wsdl import Wsdl
+            self.request = Wsdl(self)
+        else:
+            raise self.exceptions.InvalidParameterValue(
+                    "request: "+inputs["request"])
+
+        self.response = self.request.response
+        return self.response
+
+    def getConfigValue(self,*args):
+        """Return desired value from the configuration files
+
+        Keyword arguments:
+        section -- section in configuration files
+        key -- key in the section
+
+        """
+
+        value = self.config.get(*args)
+
+        # Convert Boolean string to real Boolean values
+        if value.lower() == "false":
+            value = False
+        elif value.lower() == "true" :
+            value = True
+        return value
+
+    def debug(self,debug,code="Debug"):
+        """Print debug argument to standard error
+        """
+
+        dbg = self.getConfigValue("server","debug")
+        if dbg == True or (type(dbg) == type("") and \
+                dbg.lower() == "true") or int(dbg) != 0:
+            print >>self.logFile, "PyWPS %s: %s" % (code,debug.__str__()[0:160]),
+            if len(debug.__str__()) > 160:
+                print >>self.logFile, "...",
+            print >>self.logFile, "\n"
+
+    def printResponse(self,fileDes,isSoap=False,response=None):
+        """
+        print response to file descriptor file descriptor
+        can be of type list or file
+
+        Parameters:
+            fileDes - file descriptor, where to print the result
+            isSoap - Boolean, if the response should be printed in the SOAP
+                    envelope or no
+        """
+
+        if type(fileDes) != type([]):
+            fileDes = [fileDes]
+
+        if not response:
+            response = self.response
+
+        if isSoap:
+            soap = Soap.SOAP()
+            response = soap.getResponse(response)
+
+        for f in fileDes:
+
+	    if f == STDOUT and self.stdOutClosed == True:
+		    continue
+
+            if f == STDOUT:
+                print "Content-Type: text/xml"
+                #print "Content-Length: %d" % len(self.response)
+                print ""
+
+            # open file
+            if f != STDOUT and f.closed:
+                f = open(f.name,"w")
+
+            # '""' and '"None"'s will be removed
+            f.write(re.sub(EMPTYPARAMREGEX,"",response))
+            f.flush()
+
+            if (f != STDOUT):
+                f.close()
+
+	    # remove stdout from fileDes
+	    else: 
+		self.stdOutClosed = True
+
+    def _setLogFile(self):
+        """Set self.logFile to  or something else
+        """
+
+        # logfile
+        self.logFile = STDERR
+        try:
+            self.logFile = self.getConfigValue("server","logFile")
+            if self.logFile:
+                #se = open(self.logFile, 'a+', 0)
+                #os.dup2(se.fileno(), STDERR.fileno())
+                self.logFile = open(self.logFile,"a+")
+            else:
+                self.logFile = STDERR
+        except ConfigParser.NoOptionError,e:
+            pass
+        except IOError,e:
+            traceback.print_exc(file=STDERR)
+            raise self.exceptions.NoApplicableCode("Logfile IOError: %s" % e.__str__())
+        except Exception, e:
+            traceback.print_exc(file=STDERR)
+            raise self.exceptions.NoApplicableCode("Logfile error: %s" % e.__str__())
+

Deleted: trunk/wps.py
===================================================================
--- trunk/wps.py	2010-01-06 08:06:26 UTC (rev 878)
+++ trunk/wps.py	2010-01-06 15:35:56 UTC (rev 879)
@@ -1,272 +0,0 @@
-#!/usr/bin/env python
-#-*- coding: utf-8 -*-
-"""
-This program is simple implementation of OGC's [http://opengeospatial.org]
-Web Processing Service (OpenGIS(r) Web Processing Service - OGC 05-007r7)
-version 1.0.0 from 2007-06-08
-
-Target of this application is to bring functionality of GIS GRASS
-[http://grass.itc.it] to the World Wide Web - it should work like
-wrapper for modules of this GIS. Though GRASS was at the first place in the
-focus, it is not necessary to use it's modules - you can use any program
-you can script in Python or other language.
-
-The first version was written with support of Deutsche Bundesstiftung
-Umwelt, Osnabrueck, Germany on the spring 2006. SVN server is hosted by
-GDF-Hannover, Hannover, Germany.
-
-Current development is supported mainly by:
-Help Service - Remote Sensing s.r.o
-Cernoleska 1600
-256  01 - Benesov u Prahy
-Czech Republic
-Europe
-
-For setting see comments in 'etc' directory and documentation.
-
-This program is free software, distributed under the terms of GNU General
-Public License as published by the Free Software Foundation version 2 of the
-License.
-
-Enjoy and happy GISing!
-
-$Id$
-"""
-__version__ = "3.0-svn"
-
-
-# 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.
-#
-# 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 pywps
-from pywps import Parser
-from pywps import Exceptions
-from pywps import Wps
-from pywps.Exceptions import *
-
-import sys, os, ConfigParser, urllib
-
-
-class WPS:
-    """This is main PyWPS Class, which parses the request, performs the
-    desired operation and writes required response back.
-    """
-
-    method  =""                      # HTTP POST or GET
-    parser = None
-    config = None  # Configuration
-    workingDir = None # this working directory
-
-    exceptions = pywps.Exceptions
-
-    inputs = {} # parsed input values
-    request = None # object with getcapabilities/describeprocess/execute
-                   # class
-
-    defaultLanguage = "eng"
-    languages = [defaultLanguage]
-    defaultVersion = "1.0.0"
-    versions=[defaultVersion]
-
-    # global variables
-    METHOD_GET="GET"
-    METHOD_POST="POST"
-    OWS_NAMESPACE = "http://www.opengis.net/ows/1.1"
-    WPS_NAMESPACE = "http://www.opengis.net/wps/1.0.0"
-    XLINK_NAMESPACE = "http://www.w3.org/1999/xlink"
-
-    def __init__(self):
-        """Class constructor
-
-        Will load configuration files, parse the input parameters and
-        perform the request.
-
-        """
-
-        # get settings
-        self._loadConfiguration()
-
-        # set default language
-        self.languages = self.getConfigValue("wps","lang").split(",")
-        self.defaultLanguage = self.languages[0]
-        # set default version
-        self.versions=self.getConfigValue("wps","version").split(",")
-        self.defaultVersion = self.versions[0]
-
-        # find out the request method
-        self.method = os.getenv("REQUEST_METHOD")
-        if not self.method:  # set standard method
-            self.method = self.METHOD_GET
-
-        serverPath = urllib.splithost(urllib.splittype(self.getConfigValue("wps","serveraddress"))[1])[1]
-        scriptName = os.getenv("SCRIPT_NAME")
-        restPath = None
-        try:
-            restPath= os.getenv("PATH_INFO").split(os.sep)[1:]
-        except:
-            pass
-        self.debug("%s %s %s"% (serverPath, scriptName, restPath))
-
-        # decide, which method to use
-        # HTTP GET vs. HTTP POST
-        if self.method == self.METHOD_GET:
-            from pywps.Parser.Get import Get
-            parser = Get(self)
-            querystring = ""
-            try:
-                querystring = os.environ["QUERY_STRING"]
-            except KeyError:
-                # if QUERY_STRING isn't found in env-dictionary, try to read
-                # query from command line:
-                if len(sys.argv)>1:  # any arguments available?
-                    querystring = sys.argv[1]
-            if querystring:
-                parser.parse(querystring)
-            else:
-                raise Exceptions.NoApplicableCode("No query string found.")
-        else:
-            from pywps.Parser.Post import Post
-            parser = Post(self)
-            parser.parse(sys.stdin)
-
-
-        # inputs parsed, perform request
-        if self.inputs:
-            self.debug(self.inputs)
-            self.performRequest()
-
-        # request performed, write the response back
-        if self.request.response:
-            # print only to standard out
-            if self.request.statusFiles == sys.stdout or\
-               sys.stdout in self.request.statusFiles:
-                self.request.printResponse(self.request.statusFiles,parser.isSoap)
-
-        return
-
-    def _loadConfiguration(self):
-        """Load PyWPS configuration from configuration files. This are
-
-        Both:
-        $PYWPS_CFG environment variable
-
-        Unix/Linux:
-        pywps/default.cfg
-        /etc/pywps.cfg
-        pywps/etc/pywps.cfg
-        $HOME/.pywps.cfg
-
-        Windows:
-        pywps\\default.cfg
-        pywps\\etc\\default.cfg
-
-        The later overwrites configuration from the first
-
-        """
-
-        cfgfiles = None
-
-        # configuration file as environment variable
-        if os.getenv("PYWPS_CFG"):
-
-            # Windows or Unix
-            if sys.platform == 'win32':
-                self.workingDir = os.path.abspath(os.path.join(os.getcwd(), os.path.dirname(sys.argv[0])))
-                cfgfiles = (os.path.join(self.workingDir,"pywps","default.cfg"),
-                        os.getenv("PYWPS_CFG"))
-            else:
-                cfgfiles = (os.path.join(pywps.__path__[0],"default.cfg"),
-                        os.getenv("PYWPS_CFG"))
-
-        # try to eastimate the default location
-        else:
-            # Windows or Unix
-            if sys.platform == 'win32':
-                self.workingDir = os.path.abspath(os.path.join(os.getcwd(), os.path.dirname(sys.argv[0])))
-                cfgfiles = (os.path.join(self.workingDir,"pywps","default.cfg"),
-                        os.path.join(self.workingDir, "pywps","etc","pywps.cfg"))
-            else:
-                homePath = os.getenv("HOME")
-                if homePath:
-                    cfgfiles = (os.path.join(pywps.__path__[0],"default.cfg"),
-                            os.path.join(pywps.__path__[0],"etc", "pywps.cfg"), "/etc/pywps.cfg",
-                        os.path.join(os.getenv("HOME"),".pywps.cfg" ))
-                else: 
-                    cfgfiles = (os.path.join(pywps.__path__[0],"default.cfg"),
-                            os.path.join(pywps.__path__[0],"etc",
-                                "pywps.cfg"), "/etc/pywps.cfg")
-
-        self.config = ConfigParser.ConfigParser()
-        self.config.read(cfgfiles)
-
-    def performRequest(self):
-        """Performs the desired WSP Request."""
-
-        # the modules are imported first, when the request type is known
-        if self.inputs.has_key("request"):
-            if self.inputs["request"]  == "getcapabilities":
-                from pywps.Wps.GetCapabilities import GetCapabilities
-                self.request = GetCapabilities(self)
-            elif self.inputs["request"]  == "describeprocess":
-                from pywps.Wps.DescribeProcess import DescribeProcess
-                self.request = DescribeProcess(self)
-            elif self.inputs["request"]  == "execute":
-                from pywps.Wps.Execute import Execute
-                self.request = Execute(self)
-        elif self.inputs.has_key("wsdl"):
-            self.inputs["version"]="1.0.0"
-            from pywps.Wps.Wsdl import Wsdl
-            self.request = Wsdl(self)
-        else:
-            raise self.exceptions.InvalidParameterValue(
-                    "request: "+self.inputs["request"])
-
-    def getConfigValue(self,*args):
-        """Return desired value from the configuration files
-
-        Keyword arguments:
-        section -- section in configuration files
-        key -- key in the section
-
-        """
-
-        value = self.config.get(*args)
-
-        # Convert Boolean string to real Boolean values
-        if value.lower() == "false":
-            value = False
-        elif value.lower() == "true" :
-            value = True
-        return value
-
-    def debug(self,debug,code="Debug"):
-        """Print debug argument to standard error
-        """
-
-        dbg = self.getConfigValue("server","debug")
-        if dbg == True or (type(dbg) == type("") and \
-                dbg.lower() == "true") or int(dbg) != 0:
-            print >>sys.stderr, "PyWPS %s: %s" % (code,debug.__str__()[0:160]),
-            if len(debug.__str__()) > 160:
-                print >>sys.stderr, "...",
-            print >>sys.stderr, "\n"
-
-if __name__ == "__main__":
-    wps = WPS()



More information about the Pywps-commits mailing list