[Zope-dev] Re: Zope 2.7.0 rc2 + python 2.3.3 problem

Tim Peters tim at zope.com
Tue Feb 3 11:38:01 EST 2004


[Tim Peters]
>> The globals set up for running the script appear not to contain a
>> '__file__' key, and have a '__name__' key explicitly set to None.
>> If it set either of these to something useful, or didn't have a
>> '__name__' key explicitly set to None, warning.warn() would have
>> been able to make up *something* for warn_explicit's filename and/or
>> module arguments.

[Evan Simpson]
> Argh.  Scripts need a __name__ defined, or various activities choke.
> It can't be the Id of the Script, since that can contain '.', which
> screws up imports in the Script.

Since that's mondo obscure, let's point to your explanation:

  http://mail.python.org/pipermail/python-dev/2004-January/041749.html

That's especially worth reading because of Guido's profusely apologetic
response <wink -- "Too bad.">.


> It can't be None, since that will cause this problem.
>
> Are there hidden gotchas lurking around giving all Scripts the
> __name__ "Script (Python)"?  Other suggestions?

I don't really know about Python Script, I've been talking about what
Python's warnings module does.  Perhaps you could use the Id of the script
as __name__ after Id.replace('.', '-') (i.e., get rid of the dots)?  Or it
*looks* like you could leave name None, but set '__file__' to something
(non-None) explicitly.




More information about the Zope-Dev mailing list