<div>I created and published the module myself using ScriptDomainManager.CurrentManager.CreateModule and ScriptDomainManager.CurrentManager.PublishModule.&nbsp; Hmm... I just noticed for the first time the naming inconsistency there between &quot;Module&quot; and &quot;ScriptScope&quot;.
</div>
<div>&nbsp;</div>
<div>To back up a step, I&#39;m trying to TDD an integration layer between a C# app and some Python components, and I want to be able to basically &quot;undo&quot; the test actions so it won&#39;t influence the next test.&nbsp;&nbsp;If I understand the recent DLR hosting docs correctly, at some point I should be able to accomplish the same thing by creating new ScriptRuntimes instead -- but it looks like IronPython is not yet close to allowing this.
<br></div>
<div>When you consider that there might be published ScriptScopes in many different languages then, yeah, it really complicates the potential relationship between the &quot;global object&quot; (that&#39;s global per runtime, yes?) and 
sys.modules.&nbsp; I would certainly want to be able to use DLR modules (sorry, &quot;ScriptScopes&quot;) from Python without worrying about their implementation language.&nbsp; How can I get a reference to them if not through sys.modules
?&nbsp; How do they get loaded in the first place?&nbsp; What&#39;s role does the Python loader and its extensibility mechanisms play when Python code causes a Javascript module to be loaded?</div>
<div>&nbsp;</div>
<div>Plenty of fun questions!</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div class="gmail_quote">On Jan 4, 2008 9:23 AM, Dino Viehland &lt;<a href="mailto:dinov@exchange.microsoft.com" target="_blank">dinov@exchange.microsoft.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div lang="EN-US" vlink="purple" link="blue">
<div>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">Unfortunately the answer is it depends, and it&#39;s probably not supported in Alpha 7 </span><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: Wingdings">L</span>
<span style="FONT-SIZE: 11pt; COLOR: #1f497d"> </span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">&nbsp;</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">The depends part is how the module got there and it all revolves around the design we&#39;ve come up with for the hosting of multiple languages.&nbsp; We have a global object per ScriptRuntime which is (currently) a ScriptScope.&nbsp; That scope holds onto a bunch of name/value bindings (where a value could be another nested ScriptScope) and this is the closest concept (in the DLR) we have to a module.&nbsp; The idea then is that each language exposes the global object via its own mechanism picking something that makes the most sense for that language.&nbsp; IronPython is going to expose the global object via import much like it exposes other modules and .NET namespaces.&nbsp; But that doesn&#39;t mean 
sys.modules goes away, or that sys.modules becomes the global object.&nbsp; Instead what we&#39;re currently planning on doing is having import fallback to the global object just as it falls back to the namespaces today. (As I type this I realize it does complicate this scenario – so I&#39;ll ask if this sound crazy or like a bad idea?&nbsp; Should we instead try to merge them and have 
sys.modules == global object?&nbsp; That has its own potential quirks but they could be dealt with.)</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">&nbsp;</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">So that gives two different locations where modules can be published: Either in the global object or in sys.modules.&nbsp; Therefore how you added the module effects how the module gets removed.&nbsp; If the user did &quot;import foo&quot; and we pulled up a .py file it&#39;ll end up being in 
sys.modules.&nbsp; If we pulled up a .js file from the DLR then it&#39;ll be in the global object.</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">&nbsp;</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">Further complicating things is the fact that the global object isn&#39;t really implemented yet.&nbsp; There&#39;s some remnants of the old cross-language module support we had early on but that&#39;s not really the global object.&nbsp; So for now in Alpha 7 I think the answer is that you execute the code.&nbsp; 
</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">&nbsp;</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">There&#39;s also one more future possibility: And that is that to expose Python specific functionality we may need to have a PythonEngine class or something that lets you do things that aren&#39;t part of the least common denominator.&nbsp; There accessing 
sys.modules would be a likely piece of functionality to have.</span></p>
<p><span style="FONT-SIZE: 11pt; COLOR: #1f497d">&nbsp;</span></p>
<div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; BORDER-LEFT: medium none; PADDING-TOP: 3pt; BORDER-BOTTOM: medium none">
<p><b><span style="FONT-SIZE: 10pt">From:</span></b><span style="FONT-SIZE: 10pt"> <a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a> [mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">
 users-bounces@lists.ironpython.com</a>] <b>On Behalf Of </b>Curt Hagenlocher<br><b>Sent:</b> Friday, January 04, 2008 6:03 AM<br><b>To:</b> Discussion of IronPython<br><b>Subject:</b> [IronPython] Deleting a module from the host 
</span></p></div>
<div>
<div></div>
<div>
<p>&nbsp;</p>
<div>
<p>In a previous alpha of IPY 2.0, I deleted modules by saying</p></div>
<div>
<p><span>PythonEngine.CurrentEngine.SystemState.modules.Remove(moduleName)</span></p></div>
<div>
<p>(which is almost a direct analog of &quot;del sys.modules[moduleName]&quot;).</p></div>
<div>
<p>&nbsp;</p></div>
<div>
<p>What&#39;s the best approach in Alpha 7?&nbsp; And will this change as IronPython continues to migrate to the DLR?</p></div>
<div>
<p>&nbsp;</p></div>
<div>
<p>I suppose I could literally execute Python code to do what I want, but it seems so inelegant...</p></div>
<div>
<p>&nbsp;</p></div>
<div>
<p>--</p></div>
<div>
<p>Curt Hagenlocher</p></div>
<div>
<p><a href="mailto:curt@hagenlocher.org" target="_blank">curt@hagenlocher.org</a></p></div></div></div></div></div><br>_______________________________________________<br>Users mailing list<br><a href="mailto:Users@lists.ironpython.com" target="_blank">
Users@lists.ironpython.com</a><br><a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br><br></blockquote></div><br>