From: <Mat...@i2...> - 2001-09-26 20:57:45
|
Hi all, I recently discovered jython - I must say, very cool! I'm trying to embed a jython interpreter within a java application, and I have most things working, but have a few questions: 1) With an embedded interpreter, do I still need the jython distribution directory in order for the scripts I run to have access to the standard lib (Lib\*.py)? 2) How do I add an instance of a Java object to the namespace I pass to the PythonInterpreter exec() method? 3) How do I programmatically define a python class (and instantiate it) and pass it to the interpreter as in (2) ? By programmatically I mean calling a bunch of java methods and _not_ simply evaluating a string that has my python class. 4) W.r.t (2) and (3) what I'm really trying to do is delegate to a Java instance from a Python instance so I can default some of the arguments on some methods (i.e. make a nicer interface to my java internals for the script writers). Any tips on how to do this? 5) I setup my own SecurityManager to deny exits so that scripts can't terminate my java process - anyone know of a better way to do this? 6) If no to (5), I wrap my script execution in a try/except block to catch my DenyExitSecurityException, thus enabling me to swallow the ugly stack trace when a script calls exit, however, this only works when the script calls the java System.exit(), with sys.exit() I still get the stack trace. Any idea how to stop this before I go digging around in the code? Any help appreciated, thanks, Matt mat...@i2... |