[chimera-dev] [Chimera-users] Programmer's Guide feedback....
pett at cgl.ucsf.edu
Tue Dec 15 11:24:28 PST 2009
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.
On Dec 15, 2009, at 11:10 AM, Tom Goddard wrote:
> Hi Eric,
> 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.
> -------- Original Message --------
> Subject: Re: [chimera-dev] [Chimera-users] Programmer's Guide
> From: Eric Pettersen
> To: chimera-dev
> Date: 12/15/09 10:55 AM
>> On Dec 15, 2009, at 9:36 AM, Tom Goddard wrote:
>>> 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.
>> This is a behavior of Python. We load scripts into their own
>> temporary module to avoid pollution of the Chimera main namespace
>> (e.g. 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).
>> 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.
>> Eric Pettersen
>> UCSF Computer Graphics Lab
>> Chimera-dev mailing list
>> Chimera-dev at cgl.ucsf.edu
> Chimera-dev mailing list
> Chimera-dev at cgl.ucsf.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Chimera-dev