[IronPython] (ironclad) is it possible to get the current ScriptEngine?

William Reade william at resolversystems.com
Thu Nov 20 14:36:19 CET 2008


Hi all

At the moment, when a user types 'import ironclad', I create a new 
ScriptEngine and set that up to allow .pyd imports; I then abuse 
path_hooks to use the new engine to do the imports, and copy them into 
the original engine's sys.modules. Clearly, this is evil and wrong on 
any number of levels, but so far it's been (just barely) good enough.

However, if I can find out which ScriptEngine is executing the code (so 
I can pass that into the Python25Mapper), I can greatly simplify 
ironclad.py and, hopefully, solve another user's problem (which, I 
believe, is related to sys.path not being shared between the two engines 
(quite rightly so, ofc ;))).

So: is there any way I can get a reference to the executing engine from 
within IronPython code? It feels as if it should be possible, but 
whenever I look into it I end up chasing my tail...

William



More information about the Ironpython-users mailing list