[IronPython] expose some namespaces of own application
Shri Borde
Shri.Borde at microsoft.com
Wed Aug 16 09:37:06 CEST 2006
Could you use mark the types as internal and public depending on whether you wanted to prevent or allow access from IronPython? IronPython code will not be able to access types or methods marked as internal in your C# code.
-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland
Sent: Tuesday, August 15, 2006 8:09 AM
To: Discussion of IronPython
Subject: Re: [IronPython] expose some namespaces of own application
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
_______________________________________________
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