Host Handling of changed files?

May 29, 2009 at 12:50 PM

What is the best method for the DLR host code to handle changed user code? For example, say that the user has some code in usercode.py, and that has been loaded by ExececuteFile("usercode.py", scope) and maybe also by the user via IronPython "import usercode". The user fixes an error in usercode.py, and we'd like the next Execute to reload any new source code, for, say, IronPython and IronRuby. I see that ExecuteFile will reload it (under IronPython's sys.modules["<module>"]) but I don't know what to do for sys.modules["usercode"] and other places that it might be loaded. Is there an easy way? Else, could you point me to a possible way?

Thanks for any help!

Coordinator
Jun 1, 2009 at 10:35 PM

Probably the best thing to do is to execute the file in the existing scope.  That way you don’t need to update the users reference to usercode.  But then if the user do “from usercode import *” or if they have instances of objects defined in usercode you still won’t be able to update those references. 

If you wanted something Python specific you could chase all of the objects in the world starting at sys.modules and try updating them – but there’s no automatic tracking/reloading available.

From: dsblank [mailto:notifications@codeplex.com]
Sent: Friday, May 29, 2009 5:51 AM
To: Dino Viehland
Subject: Host Handling of changed files? [dlr:57870]

From: dsblank

What is the best method for the DLR host code to handle changed user code? For example, say that the user has some code in usercode.py, and that has been loaded by ExececuteFile("usercode.py", scope) and maybe also by the user via IronPython "import usercode". The user fixes an error in usercode.py, and we'd like the next Execute to reload any new source code, for, say, IronPython and IronRuby. I see that ExecuteFile will reload it (under IronPython's sys.modules["<module>"]) but I don't know what to do for sys.modules["usercode"] and other places that it might be loaded. Is there an easy way? Else, could you point me to a possible way?

Thanks for any help!

Read the full discussion online.

To add a post to this discussion, reply to this email (dlr@discussions.codeplex.com)

To start a new discussion for this project, email dlr@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com