<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Tom,<div><span class="Apple-tab-span" style="white-space:pre"> </span>This is actually a separate instance of basically the same behavior. At Chimera startup the extension manager loads (and unloads) all the ChimeraExtension.py files. I guess we could also discuss if this behavior is critical to the extension manager and whether it's desirable to change it.</div><div><br></div><div>--Eric</div><div><br><div><div>On Dec 15, 2009, at 11:10 AM, Tom Goddard wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"> <div bgcolor="#ffffff" text="#000000"> Hi Eric,<br> <br> The case I have been burned by many times is where all globals of ChimeraExtension.py are deleted. In both the ChimeraExtension.py case and opening a *.py file with File / Open the trouble is that if the Python code registers a callback and the callback function tries to use a name in the global name space like calling another function defined in the same file or a global import then it fails. This is extremely confusing when it happens.<br> <br> Tom<br> <br> <br> -------- Original Message --------<br> Subject: Re: [chimera-dev] [Chimera-users] Programmer's Guide feedback....<br> From: Eric Pettersen<br> To: chimera-dev<br> Date: 12/15/09 10:55 AM<br> <blockquote cite="mid:61EC3E93-8EE5-48E0-AB71-4705D5162EE4@cgl.ucsf.edu" type="cite"> <div> <div>On Dec 15, 2009, at 9:36 AM, Tom Goddard wrote:</div> <br class="Apple-interchange-newline"> <blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"> 4. The ToolbarButton.py doesn't work unless the "import re" and "import chimera" are in the function body. This is because Chimera deletes all globals after loading a file. This has often been a headache for me and Chimera should not delete globals.</span></blockquote> <br> </div> <div>This is a behavior of Python. We load scripts into their own temporary module to avoid pollution of the Chimera main namespace (<i>e.g.</i> if the script defined globals named "id" or "sum" or "type" they would override built-in functions of the same name for all future script executions!). When Chimera unloads the temporary module, Python nulls out it's global namespace (to give garbage collection a shot at working).</div> <div><br> </div> <div>Now perhaps Chimera shouldn't unload the module. I think this would be a reasonable change. Perhaps it could be discussed at our next internal Chimera developers' meeting to ensure that I'm not forgetting any other ramifications that the change might have.</div> <div><br> </div> <div>--Eric</div> <br> <div> <div><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px;"> <div style=""> <div style="margin: 0px;"><font style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 16px; line-height: normal; font-size-adjust: none; font-stretch: normal;" face="Helvetica" size="5"> Eric Pettersen</font></div> <div style="margin: 0px;"><font style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 16px; line-height: normal; font-size-adjust: none; font-stretch: normal;" face="Helvetica" size="5"> UCSF Computer Graphics Lab</font></div> <div style="margin: 0px;"><font style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; font-size: 16px; line-height: normal; font-size-adjust: none; font-stretch: normal;" face="Helvetica" size="5"> <a moz-do-not-send="true" href="http://www.cgl.ucsf.edu">http://www.cgl.ucsf.edu</a></font></div> <br class="Apple-interchange-newline"> </div> </span></div> <br> </div> <pre wrap=""><hr size="4" width="90%">
_______________________________________________
Chimera-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Chimera-dev@cgl.ucsf.edu">Chimera-dev@cgl.ucsf.edu</a>
<a class="moz-txt-link-freetext" href="http://www.cgl.ucsf.edu/mailman/listinfo/chimera-dev">http://www.cgl.ucsf.edu/mailman/listinfo/chimera-dev</a>
</pre> </blockquote> <br> </div> _______________________________________________<br>Chimera-dev mailing list<br><a href="mailto:Chimera-dev@cgl.ucsf.edu">Chimera-dev@cgl.ucsf.edu</a><br>http://www.cgl.ucsf.edu/mailman/listinfo/chimera-dev<br></blockquote></div><br></div></body></html>