GeoServer : Python Scripting Extension
This page last changed on Feb 15, 2010 by jdeolive.
This page describes the GeoServer Python scripting extension.
Jython is the Java implementation of the Python language that allows Python code to execute on the JVM.
TODO: Update when added as GeoServer community module.
Python scripts are stored in the GeoServer data directory under the python/scripts directory. There is nothing special about the scripts, they are written in plain old python.
Scripts can be executed by making http calls. Consider the following very simple script:
That is located at <GEOSERVER_DATA_DIR>/python/scripts/hello.py. This script is called with the following request:
Arguments can be passed to scripts by specifying key value pairs in the query string of the request. These key value pairs end up as local variables in the script. Consider the following script:
That makes use of a local variable named greeting. To call this script:
As noted above the python/scripts directory is where scripts are located. The python/lib directory is used to store modules that are intended to be reused by multiple scripts.
Consider the following module:
Located in the file python/lib/greeting.py. Now consider the following script that makes use of the module:
Undoubtedly scripts will want to interact with GeoServer in some way. The Python extension provides an api to make this easy. The geoserver module provides a number of classes that allow for access to GeoServer:
These classes are built on top of classes from the GeoScript library that provides Python bindings for GeoTools.
Currently the extension works against Jython 2.5.1 which implements all of Python 2.5.
The extension includes a very basic interactive console available as a demo page.
The console works best in Firefox.
The following is the wish list based on feedback from teh community:
|Document generated by Confluence on May 14, 2014 23:00|