[IronPython] Passing Arguments in hosted enviroment

David Ebbo David.Ebbo at microsoft.com
Fri Sep 8 22:10:52 CEST 2006

Hi Bernd,

I would recommend against calling ExecuteFile on each request, as that would cause the code to be parsed and compiled every time (very inefficient).  Instead, one thing you can do is:

-          On the first request, create an EngineModule

-          Call ExecuteFile, passing your module

-          Find methods that you care about in EngineModule.Globals

-          Then on every request, you can call those methods, passing it arguments that are specific to the current request (e.g. the HttpContext)

You can also look at CreateLambda and CreateMethod, which may make more sense depending on your specific scenario (i.e. what kind of code you are executing).


From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Bernd Rössl
Sent: Thursday, September 07, 2006 2:40 AM
To: users at lists.ironpython.com
Subject: [IronPython] Passing Arguments in hosted enviroment

Hello list,

Great to see 1.0 prod. Is out :)

Anyway, currently i'm embedding ironpython to a web application. This gives us the ability to write extension and modules in python. One requirement is the possibility to pass arguments from the user context to the python enviroment. Till now i've done this by adding or setting object to the globals. Unfortunetly this approach isn't multi user suitable since the python enviroment is static and the same instance for all users respectivly for all sessions. So it could happen that a passed value of session2 overrides the passed value of session1.

My thoughts:

1. Each session has it's own python enviroment: this results in higher memory usage and needs time each time a session loads it's python enviroment

2. The arguments are not passed directly to the enviroment but to a session dependent object: each script has to take care what args of what session will be taken

3. ? Is there a possibility to pass args to a "ExecuteFile" context? I mean my hosting application call's the method "executeFile" each time a script will be executed and the passed args should be reachable ONLY in this execution.

What is the best solution to handle this challenge?

Thanks for your hint's!

Regards, bernd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20060908/091cf6b5/attachment.html>

More information about the Ironpython-users mailing list