[
https://issues.apache.org/jira/browse/CAMEL-7582?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14057218#comment-14057218
]
Willem Jiang commented on CAMEL-7582:
-------------------------------------
camel-script component just can get result for one line expression.
If you want to run a more complicated scripts, the script engine can store the
statements values into a value set. I just did some change in the camel
ScriptBuilder to look up the result value by using the key of "result". Now I
can get the result in multiple statements.
> Python scripts with multiple statements return null
> ---------------------------------------------------
>
> Key: CAMEL-7582
> URL: https://issues.apache.org/jira/browse/CAMEL-7582
> Project: Camel
> Issue Type: Bug
> Components: camel-language
> Affects Versions: 2.13.0
> Reporter: Tim Dudgeon
> Priority: Minor
>
> 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:
> {code}
> 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()
> {code}
--
This message was sent by Atlassian JIRA
(v6.2#6252)