I'm sending this in case my sagga helps some other relative newcomer. I suspect this problem has something to do with python1.5.2's (or Zope's hackery of...) handling of namespaces within modules & classes. What I needed was access to a "static global" variable to store some state for me. (No, I haven't looked into threads, their existance, or such issues in Zope). What I was doing was: _stateVariable=0 .... class .... def fun() .... _stateVariable=1 and this was causing me all kinds of grief. By changing the code to _stateVariable = {'a':0} ... class ... def fun() ... _stateVariable['a']=1 everything works just fine. Now, can someone give me the shortcut to understand WHHHYYY? A. -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Andrew Athan Sent: Friday, April 06, 2001 3:50 PM To: zope@zope.org Subject: RE: [Zope] Verrryy strange behavior (NameError) Ok, folks, things just got really strange indeed. The "bad" NameError behavior seems highly dependent on a line THAT NEVER EXECUTES and which occurs much AFTER where I get the exception. Namely, later on in the validate() function is the following clause (yes, I used the eval bit so that the Python byte compiler, if it does invariant optimizations, doesn't remove the code in the if). Near line 11... _xxxxxxxxxxxxx='sss' Near line 236... print 'testing=%s'%_xxxxxxxxxxxxx Near line 280... if hasattr(self,'loginForm') and \ response.unauthorized.__name__=='unauthorized': if eval('1=1')==0: print 'arghhhhhhhhhhhhhhhhhhhhhhh' _xxxxxxxxxxxxx = 1 As long as this code exists in the .py file, I get the name error. arghhhhhhhhhhhhhhhh never prints, ever (other print statements above it do). If I comment the _xxxxxxxxxxxx = 1 out, or change it to a different name, the NameError exception does not occur at line 236. If I leave it in, the exception occurs. Can you say "voodoo"? A. -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Andrew Athan Sent: Friday, April 06, 2001 3:21 PM To: zope@zope.org Subject: [Zope] Verrryy strange behavior (NameError) I'm getting an intermittent NameError trying to access a variable set in the external scope of LoginManager.py . I call my variable _x and set it directly above where _LogginInUser gets set. I then try to access it directly above a line that accesses _LoggingInUser gets accessed. I just do a simple print 'testing=%s'%_x. I get an exception. The line that accesses _LoggingInUser doesn't. What gives? Now get this ... if I change the name to (13x's) _xxxxxxxxxxxxx , it works. If I then change the name to (6x's) _xxxxxx, it continues to work. If I then change the name to (3x's) _xxx, it continues to work. (2x's) _xx works (1x's) _x doesn't work!!!! If I change the line near the top of the file from _xx='sss' to _xx=0 and change the print to use a %d I get the NameError. If I change the line back to _xx='sss' and the print back to a %s I continue to get the NameError ... even though that exact combination had worked a minute before!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! If I then change the variable back to have 13x's it starts working again. Is there some deep problem with the python byte compiler or access control mangling features of Zope? Or am I missing something stupid? What in the world is going on? A. Traceback (innermost last): File D:\CloakMail\lib\python\ZPublisher\Publish.py, line 238, in publish_module File D:\CloakMail\lib\python\ZPublisher\Publish.py, line 199, in publish File D:\CLOAKM~1\lib\python\Zope\__init__.py, line 221, in zpublisher_exception_hook (Object: Traversable) File D:\CloakMail\lib\python\ZPublisher\Publish.py, line 165, in publish File D:\CloakMail\lib\python\ZPublisher\BaseRequest.py, line 450, in traverse File D:\CloakMail\lib\python\Products\LoginManager\LoginManager.py, line 236, in validate (Object: ProviderContainer) NameError: (see above)