Closed GoogleCodeExporter closed 9 years ago
There are only one context could be entered at same time, so, if you use ctx1
in the ctx2 scope, it will not work.
Please enter the ctx1 before use it, it is a design issue
with ctx1:
r3 = ctx1.eval("f1();") # fails here with ReferenceError: f1 is not defined ( @ 1 : 0 ) -> f1();
assert r3 == 1, "assert3: expected=1, actual=%s" % r3
Original comment by flier...@gmail.com
on 10 Aug 2011 at 4:19
Thanks Flier, it works.
Sorry for the invalid issue.
PS. Should I also always exit ctx correctly? Or does the entering ctx2 always
indirectly exit ctx1 previously entered?
Original comment by viy....@gmail.com
on 10 Aug 2011 at 5:56
You are welcome :)
I prefer to use 'with' statement to manage the context scope, even you could
enter a new context before exit the current context.
with Context() as ctxt:
ctxt.eval(...)
Original comment by flier...@gmail.com
on 10 Aug 2011 at 6:01
I planned to store several ctx filled (evaluated) with heavy JS code at app
startup time.
And later (during app runtime) I need to switch between these ctx depending on
some condition.
As I now understand - it will work fine with ctx.enter() and I got rid of
reevaluating heavy JS each time.
Thanks.
Original comment by viy....@gmail.com
on 10 Aug 2011 at 6:37
If you just want to cache the script, you may try JSEngine.compile
http://code.google.com/p/pyv8/source/browse/trunk/PyV8.py#1698
Original comment by flier...@gmail.com
on 11 Aug 2011 at 2:58
Original issue reported on code.google.com by
viy....@gmail.com
on 26 Jul 2011 at 2:31