[Pywps-commits] r481 - trunk/pywps/WPS

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Apr 29 17:13:28 CEST 2008


Author: jachym
Date: 2008-04-29 17:13:28 +0200 (Tue, 29 Apr 2008)
New Revision: 481

Modified:
   trunk/pywps/WPS/Execute.py
Log:
bugfix in reference output

Modified: trunk/pywps/WPS/Execute.py
===================================================================
--- trunk/pywps/WPS/Execute.py	2008-04-29 14:44:52 UTC (rev 480)
+++ trunk/pywps/WPS/Execute.py	2008-04-29 15:13:28 UTC (rev 481)
@@ -25,7 +25,7 @@
 
 from Request import Request
 import time,os,sys,tempfile,re
-from shutil import copy as COPY
+from shutil import copyfile as COPY
 from shutil import rmtree as RMTREE
 
 class Execute(Request):
@@ -453,9 +453,7 @@
         for identifier in self.process.outputs.keys():
             templateOutput = {}
             output = self.process.outputs[identifier]
-            pr
 
-
             templateOutput["identifier"] = output.identifier
             templateOutput["title"] = output.title
             templateOutput["abstract"] = output.abstract
@@ -511,7 +509,7 @@
 
             # Reference
             if output.asReference:
-                self._asReferenceOutput(templateOutput, output)
+                templateOutput = self._asReferenceOutput(templateOutput, output)
             # Data
             else:
                 templateOutput["reference"] = 0
@@ -522,7 +520,7 @@
                 elif output.type == "BoundingBoxValue":
                     templateOutput = self._bboxOutput(output,templateOutput)
 
-                templateOutputs.append(templateOutput);
+            templateOutputs.append(templateOutput);
         self.templateProcessor.set("Outputs",templateOutputs)
 
     def _literalOutput(self, output, literalOutput):
@@ -561,6 +559,7 @@
 
     def _asReferenceOutput(self,templateOutput, output):
 
+        
         # copy the file to output directory
         if output.type == "LiteralValue":
             f = open(os.path.join(
@@ -568,17 +567,24 @@
                                 output.identifier+"-"+self.pid),"w")
             f.write(output.value)
             f.close()
-            templateOutput["href"] = self.wps.getConfigValue("server","outputUrl")+\
-                    "/"+output.identifier+"-"+self.pid
+            templateOutput["reference"] = self.wps.getConfigValue("server","outputUrl")+\
+                    "/"+output.identifier+"-"+str(self.pid)
         else:
-            COPY(output.value, self.wps.getConfigValue("server","outputPath"))
-            templateOutput["href"] = \
-                    self.wps.getConfigValue("server","outputUrl")+"/"+output.value
-        templateOutput["reference"] = 1
+            outName = output.value
+            outSuffix = outName.split(".")[len(outName.split("."))-1]
+            outName = output.identifier+"-"+str(self.pid)+"."+outSuffix
+
+            COPY(output.value, self.wps.getConfigValue("server","outputPath")+"/"+outName)
+            templateOutput["reference"] = \
+                    self.wps.getConfigValue("server","outputUrl")+"/"+outName
         templateOutput["mimetype"] = output.format["mimeType"]
         templateOutput["schema"] = output.format["encoding"]
         templateOutput["encoding"] = output.format["schema"]
 
+        return templateOutput
+
+    # --------------------------------------------------------------------
+
     def splitThreads(self):
         """
         Will 'try' to for currently running process. Parent process will



More information about the Pywps-commits mailing list