From d5a742944e3cbaa471051e50bc918698461f4996 Mon Sep 17 00:00:00 2001 From: David Huynh Date: Sun, 21 Nov 2010 03:05:28 +0000 Subject: [PATCH] Set python.path properly from within the jython extension git-svn-id: http://google-refine.googlecode.com/svn/trunk@1920 7d457c2a-affb-35e4-300a-418c747d4874 --- extensions/jython/module/MOD-INF/controller.js | 13 +++++++++++-- refine | 7 ------- server/src/com/google/refine/Refine.java | 5 ----- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/extensions/jython/module/MOD-INF/controller.js b/extensions/jython/module/MOD-INF/controller.js index 429a69aba..a0ff6dcf2 100644 --- a/extensions/jython/module/MOD-INF/controller.js +++ b/extensions/jython/module/MOD-INF/controller.js @@ -32,8 +32,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ function init() { - // Packages.java.lang.System.err.println("Initializing jython extension"); - + var libPath = new Packages.java.io.File(module.getPath(), "MOD-INF/lib/jython/").getCanonicalPath(); + + var S = Packages.java.lang.System; + var currentLibPath = S.getProperty("python.path"); + if (currentLibPath == null) { + currentLibPath = libPath; + } else if (currentLibPath.indexOf(libPath) < 0) { + currentLibPath = currentLibPath + Packages.java.io.File.pathSeparator + libPath; + } + S.setProperty("python.path", currentLibPath); + Packages.com.google.refine.expr.MetaParser.registerLanguageParser( "jython", "Jython", diff --git a/refine b/refine index 56e39d8dc..176e25d4a 100755 --- a/refine +++ b/refine @@ -910,13 +910,6 @@ if [ -z "$REFINE_VERBOSITY" ] ; then fi add_option "-Drefine.verbosity=$REFINE_VERBOSITY" -if [ -z "$JYTHONPATH" ] ; then - JYTHONPATH="$REFINE_WEBAPP/WEB-INF/lib/jython" -else - JYTHONPATH="$REFINE_WEBAPP/WEB-INF/lib/jython${SEP}$JYTHONPATH" -fi -add_option "-Dpython.path=$JYTHONPATH" - # ----- Respond to the action given -------------------------------------------- case "$ACTION" in diff --git a/server/src/com/google/refine/Refine.java b/server/src/com/google/refine/Refine.java index 855c51f60..b6383c430 100644 --- a/server/src/com/google/refine/Refine.java +++ b/server/src/com/google/refine/Refine.java @@ -94,11 +94,6 @@ public class Refine { // tell the signpost library to log //System.setProperty("debug","true"); - - // if not already set, make sure jython can find its python stuff - if (System.getProperty("python.path") == null) { - System.setProperty("python.path","lib/python"); - } // set the log verbosity level org.apache.log4j.Logger.getRootLogger().setLevel(Level.toLevel(Configurations.get("refine.verbosity","info")));