Message6766
The change of behaviour from 2.2.1 to 2.5.2 might be considered an issue (in need of documentation?), but looking athe code, the motive appears to have been an improvement.
On the whole, I think this were better considered a usage question than an issue.
The PyDictionary accepts and initial value for its Map, but it makes a private copy. The client can access it with PyDictionary.getMap(). That's a way I haven't tried as there appears to be a cleaner way.
This code, adapted from the user's example works for me on 2.5.2:
package X;
import org.python.core.CompileMode;
import org.python.core.Py;
import org.python.core.PyCode;
import org.python.core.PyDictionary;
import org.python.core.PySystemState;
import org.python.util.PythonInterpreter;
public class SolveIssue1827 {
public static void main(String[] args) {
// Compile the example program for the Python interpreter
String scriptSource = "svc_params['SH_CAMPAIGN_ID'] = 'CAMPAIGN_ID'";
PyCode pyCode = Py.compile_flags(scriptSource, "<string>", CompileMode.exec,
Py.getCompilerFlags(0, false));
// Create an interpreter
PySystemState.initialize();
PythonInterpreter interp = new PythonInterpreter(null);
// Create a dictionary for exchange
PyDictionary ioDictionary = new PyDictionary();
interp.set("svc_params", ioDictionary);
// Run the code and show that the exchange dictionary contains the result
interp.exec(pyCode);
System.out.println("*************** " + ioDictionary);
}
}
I get the output:
*************** {'SH_CAMPAIGN_ID': 'CAMPAIGN_ID'}
Close?
Jeff |
|
Date |
User |
Action |
Args |
2012-01-28 21:48:10 | jeff.allen | set | messageid: <1327787290.84.0.640937449656.issue1827@psf.upfronthosting.co.za> |
2012-01-28 21:48:10 | jeff.allen | set | recipients:
+ jeff.allen, fwierzbicki, neelemab |
2012-01-28 21:48:10 | jeff.allen | link | issue1827 messages |
2012-01-28 21:48:10 | jeff.allen | create | |
|