Message4995
In Subversion revision 6633.
The issue is that sometimes a ScriptEngine can be re-used, but called
with a different context. Why do this? Lots of reasons! In applications
that use scripts a lot, it's a waste of resources to recreate the
ScriptEngine all over again. Instead, it is reused, while only a
different context is used. This is how I've implemented in the
Scripturian project, and it works fine for every other JSR-223-compliant
engine supported (include Jython 2.2 with its JSR-223 support library).
This was quite easy to fix. I'm unsure how to submit a patch, but I hope
this will suffice! Here is PyScriptEngine with my addition:
private Object eval(PyCode code, ScriptContext context) throws
ScriptException {
try {
interp.setIn(context.getReader());
interp.setOut(context.getWriter());
interp.setErr(context.getErrorWriter());
List<Integer> scopes = context.getScopes();
for (int scope : scopes) {
this.context.setBindings( context.getBindings( scope ),
scope );
}
return interp.eval(code).__tojava__(Object.class);
} catch (PyException pye) {
throw scriptException(pye);
}
} |
|
Date |
User |
Action |
Args |
2009-08-06 05:19:45 | emblemparade | set | recipients:
+ emblemparade |
2009-08-06 05:19:44 | emblemparade | set | messageid: <1249535984.97.0.23490289182.issue1426@psf.upfronthosting.co.za> |
2009-08-06 05:19:44 | emblemparade | link | issue1426 messages |
2009-08-06 05:19:43 | emblemparade | create | |
|