Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
2.13.0
-
None
-
Unknown
Description
As reported here:
http://camel.465427.n5.nabble.com/Return-Value-from-Python-Script-Not-In-Message-Body-tt5724056.html#none
It seems that when calling python script that has more than a single statement the return value from the script is null. Here is a simple example in groovy that shows this:
package com.im.examples import org.apache.camel.* import org.apache.camel.impl.* import org.apache.camel.builder.* String script = URLEncoder.encode('"Hello world!"', "UTF-8") // this works - script returns "Hello world!" //String script = URLEncoder.encode('bar = "baz"; "Hello world!"', "UTF-8") // this fails - script returns null CamelContext camelContext = new DefaultCamelContext() camelContext.addRoutes(new RouteBuilder() { def void configure() { from("direct:python") .to("language:python:" + script) } } ) camelContext.start() ProducerTemplate t = camelContext.createProducerTemplate() def result = t.requestBody('direct:python', 'foo') println result camelContext.stop()