Changeset 396


Ignore:
Timestamp:
Mar 26, 2013, 5:10:36 PM (10 years ago)
Author:
lucadelu
Message:

improve documentation for python services

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/services/howtos.txt

    r348 r396  
    2525
    2626.. Note:: For each Service provided by your ZOO Python Services Provider, the ZCFG File
    27           must be named the same as the Python module function name.
     27          must be named the same as the Python module function name (also the case of
     28          characters is important).
    2829
    2930The ZCFG file should contain the following :
     
    4041**************************
    4142
    42 The Python module's function to be used as a service must:
     43The Python module's function to be used take three arguments: the main configuration, inputs and outputs.
     44All this values are passed to the Python module as dictionaries.
    4345
    44 - take three arguments : the main configuration, inputs and outputs maps are passed to the
    45   Python module as dictionaries.
    46 - return an integer : corresponding to the service status code.
     46Following you'll find an example for each parameters
    4747
    48 Sample Data Structure
    49 *********************
     48Main configuration
     49^^^^^^^^^^^^^^^^^^^^^
     50Main configuration contains several informations, some of them are really useful to develop your service.
     51Following an example ::
    5052
    51 In the following you'll find a sample argument passed to the Python module's function for
    52 the two first main configuration file' sections.
     53  {
     54  'main': {'lang': 'en-UK',
     55           'language': 'en-US',
     56           'encoding': 'utf-8',
     57           'dataPath': '/var/www/tmp',
     58           'tmpPath': '/var/www/tmp',
     59           'version': '1.0.0',
     60           'mapserverAddress': 'http://localhost/cgi-bin/mapserv',
     61           'isSoap': 'false',
     62           'tmpUrl': 'http://localhost/tmp/',
     63           'serverAddress': 'http://localhost/zoo'
     64          },
     65  'identification': {'keywords': 'WPS,GIS',
     66                     'abstract': 'WPS services for testing ZOO',
     67                     'fees': 'None',
     68                     'accessConstraints': 'none',
     69                     'title': 'testing services'
     70                    },
     71  'lenv': {'status': '0',
     72           'soap': 'false',
     73           'cwd': '/usr/lib/cgi-bin',
     74           'sid': '24709'
     75          },
     76  'env': {'DISPLAY': 'localhost:0'},
     77  'provider': {'addressCountry': 'it',
     78               'positionName': 'Developer',
     79               'providerName': 'Name of provider',
     80               'addressAdministrativeArea': 'False',
     81               'phoneVoice': 'False',
     82               'addressCity': 'City',
     83               'providerSite': 'http://www.your.site',
     84               'addressPostalCode': '38122',
     85               'role': 'Developer',
     86               'addressDeliveryPoint': 'False',
     87               'phoneFacsimile': 'False',
     88               'addressElectronicMailAddress': 'your@email.com',
     89               'individualName': 'Your Name'
     90              }
     91  }
    5392
    54 ::
     93Inputs
     94^^^^^^^^^^^^
     95The inputs are somethings like this ::
    5596
    56   main={
    57      "main": {"encoding": "utf-8",
    58               "version": "1.0.0",
    59               "serverAddress": "http://www.zoo-project.org/zoo/",
    60               "lang": "fr-FR,en-CA"},
    61      "identification": {"title": "The Zoo WPS Development Server",
    62                         "abstract": "Development version of ZooWPS.",
    63                         "fees": "None",
    64                         "accessConstraints": "none",
    65                         "keywords": "WPS,GIS,buffer"}
     97  {
     98  'variable_name': {'minOccurs': '1',
     99                    'DataType': 'string',
     100                    'value': 'this_is_the_value',
     101                    'maxOccurs': '1',
     102                    'inRequest': 'true'
     103                   }
    66104  }
     105
     106The access to the value you have to require for the ``value`` parameter, something like this ::
     107
     108  yourVariable = inputs['variable_name']['value']
     109
     110Outputs
     111^^^^^^^^^^^^^
     112The outputs data as a structure really similar to the inputs one ::
     113
     114  {
     115  'result': {'DataType': 'string',
     116             'inRequest': 'true',
     117            }
     118  }
     119
     120There is no ``'value'`` parameter before you assign it ::
     121
     122  inputs['result']['value'] = yourOutputDataVariable
     123
     124The return statement has to be an integer: corresponding to the service status code.
     125
     126The module should **return 3 if the process successfully ended otherwise it should return 4**.
     127To add a message for the wrong result you can add the massage to ``conf["lenv"]["message"]``,
     128for example:
     129
     130.. code-block:: python
     131
     132  conf["lenv"]["message"] = 'Your module return an error'
    67133
    68134Sample ZOO Python Services Provider
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png