[IronPython] sandboxing

2008-08-22 Thread Huzaifa
private static PermissionSet ps = new PermissionSet(PermissionState.None); ps.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution)); ps.AddPermission(new FileIOPermission(FileIOPermissionAccess.PathDiscovery | FileIOPermissionAccess.Read, Path)); public static vo

Re: [IronPython] How to call a function passing parameters

2008-08-22 Thread Christian Schmidt
Hi Fernando, try this: ScriptEngine engine = ScriptRuntime.Create().GetEngine("py"); ScriptScope scope = engine.CreateScope(); scope.Execute(@" def test(a): return a "); string my_a = "A"; object func = scope.GetVariable("test"); object result = engine.Operations.Call(func, my_a); Console.Write

Re: [IronPython] How to call a function passing parameters

2008-08-22 Thread Seshadri Pillailokam Vijayaraghavan
You can also find a blog post and a self containing sample on what you are trying to do here - http://blogs.msdn.com/seshadripv/archive/2008/06/30/how-to-invoke-a-python-function-from-c-using-the-dlr-hosting-api.aspx Thanks sesh -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL

Re: [IronPython] How to call a function passing parameters

2008-08-22 Thread Tomas Matousek
You can do: var runtime = ScriptRuntime.Create(); var scope = runtime.CreateScope("python"); scope.Execute(@" def test(a): return a "); var test = scope.GetVariable>("test"); Console.WriteLine(test(my_a)); Tomas -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On

[IronPython] How to call a function passing parameters

2008-08-22 Thread Fernando Correia
Please help me to call an IronPython function passing parameters from a C# method. Let's say I have a ScriptEngine and also a ScriptScope. In the scope I have a Python function like this: def test(a): return a Then in some C# method I have something like: string my_a = "A"; How can I call

[IronPython] Re strict imports

2008-08-22 Thread Huzaifa
how can i restrict my user that he can not perform any imports or I/O operations in the script. -- View this message in context: http://www.nabble.com/Restrict-imports-tp19113682p19113682.html Sent from the IronPython mailing list archive at Nabble.com. _

Re: [IronPython] CustomSymbolDictionary and conversions

2008-08-22 Thread Seshadri Pillailokam Vijayaraghavan
Hi Christian, Hope these answer your questions... >When accessing the baseScope from your example, isn't >SymbolTable.IdToString(key) for each access to the baseScope slow? >I wonder, why there is no ScriptScope.GetVariable(SymbolId) method. The number of scenarios where a user would invoke any