[Pywps-commits] r960 - in trunk: pywps/Process pywps/Templates/1_0_0 pywps/Wps tests/processes

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Jul 1 14:25:10 CEST 2010


Author: jachym
Date: 2010-07-01 14:25:10 +0200 (Thu, 01 Jul 2010)
New Revision: 960

Modified:
   trunk/pywps/Process/__init__.py
   trunk/pywps/Templates/1_0_0/DescribeProcess.tmpl
   trunk/pywps/Templates/1_0_0/Execute.tmpl
   trunk/pywps/Templates/1_0_0/GetCapabilities.tmpl
   trunk/pywps/Wps/DescribeProcess.py
   trunk/pywps/Wps/Execute.py
   trunk/pywps/Wps/GetCapabilities.py
   trunk/pywps/Wps/__init__.py
   trunk/tests/processes/tests.py
Log:
formating metadata, see discussion at http://wald.intevation.org/tracker/?func=detail&atid=302&aid=1532&group_id=22

Modified: trunk/pywps/Process/__init__.py
===================================================================
--- trunk/pywps/Process/__init__.py	2010-07-01 09:07:46 UTC (rev 959)
+++ trunk/pywps/Process/__init__.py	2010-07-01 12:25:10 UTC (rev 960)
@@ -115,11 +115,17 @@
     :type title: string
     :param abstract: process description
     :type abstract: string
-    :param metadata: List of additional metadata references. See http://www.opengeospatial.org/standards/common, table 32 on page 65
+    :param metadata: List of additional metadata references. See http://www.opengeospatial.org/standards/common, table 32 on page 65, http://schemas.opengis.net/xlink/1.0.0/xlinks.xsd
 
            Example::
             
-                ["http://bnhelp.cz/metadata/micka_main.php?ak=detail&uuid=32e80880-c3b0-11dc-8641-873e117140a9"]
+                [
+                    {
+                     "title": "Title",
+                     "href": "http://bnhelp.cz/metadata/micka_main.php?ak=detail&uuid=32e80880-c3b0-11dc-8641-873e117140a9",
+                     ... : ...
+                     }
+                ]
 
     :param profile: profile URN
     :type profile: [string]
@@ -343,11 +349,17 @@
                     default: types.IntType
         :type type: `types.TypeType`
         :param default: default value of this input
-        :param metadata: List of additional metadata references. See http://www.opengeospatial.org/standards/common, table 32 on page 65
+        :param metadata: List of additional metadata references. See http://www.opengeospatial.org/standards/common, table 32 on page 65, http://schemas.opengis.net/xlink/1.0.0/xlinks.xsd
 
-           Example::
-            
-                {"Title of metadata link":"http://bnhelp.cz/metadata/micka_main.php?ak=detail&uuid=32e80880-c3b0-11dc-8641-873e117140a9"}
+            Example::
+                
+                    [
+                        {
+                        "title": "Title",
+                        "href": "http://bnhelp.cz/metadata/micka_main.php?ak=detail&uuid=32e80880-c3b0-11dc-8641-873e117140a9",
+                        ... : ...
+                        }
+                    ]
         
             default: None
 
@@ -389,12 +401,18 @@
         :param maxmegabites: Maximum input file size. Can not be bigger, as
                 defined in global configuration file.
 
-        :param metadata: List of additional metadata references. See http://www.opengeospatial.org/standards/common, table 32 on page 65
+        :param metadata: List of additional metadata references. See http://www.opengeospatial.org/standards/common, table 32 on page 65, http://schemas.opengis.net/xlink/1.0.0/xlinks.xsd
 
-           Example::
-            
-                ["http://bnhelp.cz/metadata/micka_main.php?ak=detail&uuid=32e80880-c3b0-11dc-8641-873e117140a9"]
-        
+            Example::
+                
+                    [
+                        {
+                        "title": "Title",
+                        "href": "http://bnhelp.cz/metadata/micka_main.php?ak=detail&uuid=32e80880-c3b0-11dc-8641-873e117140a9",
+                        ... : ...
+                        }
+                    ]
+
             default: None
         
         :returns: :class:`pywps.Process.InAndOutputs.ComplexInput`
@@ -444,12 +462,18 @@
 
         :param identifier: output identifier
         :param title: output title
-        :param metadata: List of additional metadata references. See http://www.opengeospatial.org/standards/common, table 32 on page 65
+        :param metadata: List of additional metadata references. See http://www.opengeospatial.org/standards/common, table 32 on page 65, http://schemas.opengis.net/xlink/1.0.0/xlinks.xsd
 
-           Example::
-            
-                ["http://bnhelp.cz/metadata/micka_main.php?ak=detail&uuid=32e80880-c3b0-11dc-8641-873e117140a9"]
-        
+            Example::
+                
+                    [
+                        {
+                        "title": "Title",
+                        "href": "http://bnhelp.cz/metadata/micka_main.php?ak=detail&uuid=32e80880-c3b0-11dc-8641-873e117140a9",
+                        ... : ...
+                        }
+                    ]
+
             default: None
 
         :param formats: List of dictionaries according to table 23 (page

Modified: trunk/pywps/Templates/1_0_0/DescribeProcess.tmpl
===================================================================
--- trunk/pywps/Templates/1_0_0/DescribeProcess.tmpl	2010-07-01 09:07:46 UTC (rev 959)
+++ trunk/pywps/Templates/1_0_0/DescribeProcess.tmpl	2010-07-01 12:25:10 UTC (rev 960)
@@ -9,7 +9,7 @@
         <ows:Abstract><TMPL_VAR abstract></ows:Abstract>
         </TMPL_IF>
         <TMPL_LOOP Metadata>
-        <ows:Metadata xlink:title="<TMPL_VAR metadata>" />
+        <ows:Metadata xlink:title="<TMPL_VAR title>" xlink:href="<TMPL_VAR href>" />
         </TMPL_LOOP>
         <TMPL_LOOP Profiles>
         <wps:Profile><TMPL_VAR profile></wps:Profile>

Modified: trunk/pywps/Templates/1_0_0/Execute.tmpl
===================================================================
--- trunk/pywps/Templates/1_0_0/Execute.tmpl	2010-07-01 09:07:46 UTC (rev 959)
+++ trunk/pywps/Templates/1_0_0/Execute.tmpl	2010-07-01 12:25:10 UTC (rev 960)
@@ -7,7 +7,7 @@
         <ows:Abstract><TMPL_VAR abstract></ows:Abstract>
         </TMPL_IF>
         <TMPL_LOOP Metadata>
-        <ows:Metadata xlink:title="<TMPL_VAR metadata>" />
+        <ows:Metadata xlink:title="<TMPL_VAR title>" xlink:href="<TMPL_VAR href>" />
         </TMPL_LOOP>
         <TMPL_LOOP Profiles>
         <wps:Profile><TMPL_VAR profile></wps:Profile>

Modified: trunk/pywps/Templates/1_0_0/GetCapabilities.tmpl
===================================================================
--- trunk/pywps/Templates/1_0_0/GetCapabilities.tmpl	2010-07-01 09:07:46 UTC (rev 959)
+++ trunk/pywps/Templates/1_0_0/GetCapabilities.tmpl	2010-07-01 12:25:10 UTC (rev 960)
@@ -109,7 +109,7 @@
 			<ows:Abstract><TMPL_VAR abstract></ows:Abstract>
                         </TMPL_IF>
                         <TMPL_LOOP Metadata>
-                        <ows:Metadata xlink:href="<TMPL_VAR metadata>" />
+                        <ows:Metadata xlink:title="<TMPL_VAR title>" xlink:href="<TMPL_VAR href>" />
                         </TMPL_LOOP>
                         <TMPL_LOOP Profiles>
 			<wps:Profile><TMPL_VAR profile></wps:Profile>

Modified: trunk/pywps/Wps/DescribeProcess.py
===================================================================
--- trunk/pywps/Wps/DescribeProcess.py	2010-07-01 09:07:46 UTC (rev 959)
+++ trunk/pywps/Wps/DescribeProcess.py	2010-07-01 12:25:10 UTC (rev 960)
@@ -77,10 +77,7 @@
             if process.abstract:
                 processData["abstract"] = process.i18n(process.abstract)
             if process.metadata:
-                metadata=[]
-                for meta in process.metadata:
-                    metadata.append({"metadata":meta})
-                processData["Metadata"] = metadata
+                processData["Metadata"] = self.formatMetadata(process)
             if process.profile:
                 profiles=[]
                 if type(process.profile) == types.ListType:

Modified: trunk/pywps/Wps/Execute.py
===================================================================
--- trunk/pywps/Wps/Execute.py	2010-07-01 09:07:46 UTC (rev 959)
+++ trunk/pywps/Wps/Execute.py	2010-07-01 12:25:10 UTC (rev 960)
@@ -472,12 +472,13 @@
                     input.maxFileSize = maxFileSize
 
             try:
-                for inp in self.wps.inputs["datainputs"]:
-                    if unicode(inp["identifier"]) == unicode(identifier):
-                        resp = input.setValue(inp)
-                        if resp:
-                            self.cleanEnv()
-                            raise pywps.InvalidParameterValue(resp)
+                if self.wps.inputs["datainputs"]:
+                    for inp in self.wps.inputs["datainputs"]:
+                        if unicode(inp["identifier"]) == unicode(identifier):
+                            resp = input.setValue(inp)
+                            if resp:
+                                self.cleanEnv()
+                                raise pywps.InvalidParameterValue(resp)
             except KeyError,e:
                 pass
 
@@ -588,10 +589,7 @@
         if self.process.abstract:
             self.templateProcessor.set("abstract", self.process.i18n(self.process.abstract))
         if self.process.metadata:
-            metadata=[]
-            for meta in self.process.metadata:
-                metadata.append({"metadata":meta})
-            self.templateProcessor.set("Metadata", metadata)
+            self.templateProcessor.set("Metadata", self.formatMetadata(self.process))
         if self.process.profile:
             profiles=[]
             if type(self.process.profile) == types.ListType:

Modified: trunk/pywps/Wps/GetCapabilities.py
===================================================================
--- trunk/pywps/Wps/GetCapabilities.py	2010-07-01 09:07:46 UTC (rev 959)
+++ trunk/pywps/Wps/GetCapabilities.py	2010-07-01 12:25:10 UTC (rev 960)
@@ -155,10 +155,7 @@
                 if process.abstract:
                     processData["abstract"] = process.i18n(process.abstract)
                 if process.metadata:
-                    metadata=[]
-                    for meta in process.metadata:
-                        metadata.append({"metadata":meta})
-                    processData["Metadata"] = metadata
+                    processData["Metadata"] = self.formatMetadata(process)
                 if process.profile:
                     profiles=[]
                     if type(process.profile) == types.ListType:

Modified: trunk/pywps/Wps/__init__.py
===================================================================
--- trunk/pywps/Wps/__init__.py	2010-07-01 09:07:46 UTC (rev 959)
+++ trunk/pywps/Wps/__init__.py	2010-07-01 12:25:10 UTC (rev 960)
@@ -370,3 +370,33 @@
             else:
                 return processes
 
+    def formatMetadata(self,process):
+        """Create structure suitble for template form process.metadata
+
+        :param process: :attr:`pywps.Process`
+        :returns: hash with formated metadata
+        """
+
+        metadata = process.metadata
+        if type(metadata) == type({}):
+            metadata = [metadata]
+
+        metadatas = []
+        for metad in metadata:
+            metaStructure = {}
+
+            if metad.has_key("title"):
+                metaStructure["title"] = metad["title"]
+            else:
+                metaStructure["title"] = process.title
+
+            if metad.has_key("href"):
+                metaStructure["href"] = metad["href"]
+            else:
+                metaStructure["href"] = config.getConfigValue("wps","serveraddress")+\
+                        "?service=WPS&request=DescribeProcess&version="+config.getConfigValue("wps","version")+\
+                        "&identifier="+ process.identifier
+
+            metadatas.append(metaStructure)
+
+        return metadatas

Modified: trunk/tests/processes/tests.py
===================================================================
--- trunk/tests/processes/tests.py	2010-07-01 09:07:46 UTC (rev 959)
+++ trunk/tests/processes/tests.py	2010-07-01 12:25:10 UTC (rev 960)
@@ -12,7 +12,11 @@
 
     def __init__(self):
         WPSProcess.__init__(self, identifier = "literalprocess",
-                title="Literal process",metadata=["http://foo/bar","http://bar/foo"])
+                title="Literal process",
+                metadata=[{"title":"Foobar","href":"http://foo/bar"},
+                          {"title":"Barfoo","href":"http://bar/foo"},
+                          {"title":"Literal process"},
+                          {"href":"http://foobar/"}])
 
         self.intIn = self.addLiteralInput(identifier="int",
                                                  title="Integer data in")



More information about the Pywps-commits mailing list