Re: [chimera-dev] [Chimera] #7111: problem with "toolbar buttons" programmer's example (was: Chimera bug report submission)

Hi Richard, The issue here is that Chimera executes Python scripts in temporary modules so that they don't interact with Chimera's own global namespace (they don't accidentally pick up names from the global namespace nor do they leave definitions there). After the script is executed, the temporary module is deleted from sys.modules. When that happens Python clears references in the module's globals dictionary by setting the values to None in an attempt to break circular references for garbage-collection and destructor-invocation purposes. So... the script's attempt to use those names later (when the toolbar button is pressed) produces the "'NoneType' object has no attribute 'compile'" error since when Python looks up "re" in the module's globals dictionary it gets 'None' back. The fix is to put "import re" inside the function definition (as well as an additional "import chimera" [an import is still required at the global level for code after the button-callback function]). I will need to update the example to account for this behavior. The example was written back when scripts were executed in Chimera's own namespace. --Eric On Apr 1, 2009, at 11:36 AM, Chimera wrote:
#7111: problem with "toolbar buttons" programmer's example ----------------------------------------------- +---------------------------- Reporter: richard.marhoefer@… | Owner: pett Type: defect | Status: accepted Priority: normal | Milestone: Release 1.4 Component: Core | Version: 1.0 (build 2540) Severity: normal | Keywords: Blockedby: | Project: chimera Platform: all | Blocking: ----------------------------------------------- +---------------------------- Changes (by pett):
* status: new => accepted * reporter: chimera-bug-report@… => richard.marhoefer@… * component: => Core * project: => chimera * platform: => all * version: => 1.0 (build 2540) * milestone: => Release 1.4 * owner: => pett
-- Ticket URL: <http://socrates2.cgl.ucsf.edu/trac/chimera/ticket/7111#comment:2
Chimera <http://socrates2.cgl.ucsf.edu/trac/chimera> Chimera Issue Tracker
participants (1)
-
Eric Pettersen