[IronPython] expose some namespaces of own application
Dino Viehland
dinov at exchange.microsoft.com
Tue Aug 15 17:08:33 CEST 2006
It is currently an all-or-nothing situation. As a work around you could create your own module (import imp.new_module('modulename')) and then you could add the namespaces onto the new module, then publish the module in sys.modules:
import imp
import sys
mod = imp.new_module('test')
mod.abc = 'xyz'
sys.modules['test'] = mod
import test
print test.abc
You can do this w/o giving IronPython the reference to your assembly. Just load the assembly, and from Python you can access the namespaces/types directly off the assembly object.
-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Stanislas Pinte
Sent: Tuesday, August 15, 2006 12:34 AM
To: Discussion of IronPython
Subject: [IronPython] expose some namespaces of own application
Hello,
We are using IP as a scripting engine, embedded in one of our products.
I would like to be able to expose a subset of the namespaces present in my application assembly (MyApp.exe) to the scripting engine...but hide the rest:
i.e. when a user does an "from a.b.c import Bar", if a.b.c is "hidden", then it fails:
>>> from a.b.c import Bar
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named a.b.c
>>>
whereas if a.b.pub has been "exposed" to the scripting engine, then the user can import it.
Is this currently possible? I have the impression that it is an all-or-nothing situation...and I would like to avoid having to split my classes in several assemblies.
Thanks for all input,
Kind regards,
Stan.
--
-----------------------------------------------------------------
Stanislas Pinte e-mail: stan at ertmssolutions.com
ERTMS Solutions http://www.ertmssolutions.com
Rue de l'Autonomie, 1 Tel: + 322 - 522.06.63
1070 Bruxelles Fax: + 322 - 522.09.30
-----------------------------------------------------------------
Skype (http://www.skype.com) id: stanpinte
-----------------------------------------------------------------
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
More information about the Ironpython-users
mailing list