|
Daniel West
dwmp at opti.cgi.net
Fri Jan 9 10:12:57 EST 2004
Try assigning global SSDefaultDir at the top of your SSInit function like this:
def SSInit(SessionDir):
global SSDefaultDir
SSLock()
...
-Dan
At 04:19 PM 1/9/2004 +0100, you wrote:
>Hello !
>
>I have get a strange problem in mod_python site.
>More modules I have, and think, to I initialize my Session handler
>from main module.
>
>Like this:
>
>-- main --
>
>import BHASession
>
># Session info
>BHASessionDir="C:/bhaweb/sessions"
>#f=open("c:/now.txt","a");f.write(" 1");f.close();
>BHASession.SSInit(BHASessionDir)
>#f=open("c:/now.txt","a");f.write(" 2");f.close();
>
>-- Session --
>f=open("c:/now.txt","a");f.write(" 01");f.close();
>#global SSDefaultDir
>SSDefaultDir="c:/bhaweb/sessions"
>f=open("c:/now.txt","a");f.write(" 02");f.close();
>SSLockObj=threading.Lock()
>
>def SSLock():
> SSLockObj.acquire()
>
>def SSUnlock():
> SSLockObj.release()
>
>def SSInit(SessionDir):
> #f=open("c:/now.txt","a");f.write(" 03");f.close();
> SSLock()
> try:
> #global SSDefaultDir
> #r.append(str(SSDefaultDir))
> #f=open("c:/now.txt","a")
> #f.write(" "+SSDefaultDir)
> #f.close()
> #r.append(str(SSInitialized))
> if SSDefaultDir.strip()=="":
># <-
># UnboundLocalError: local variable 'SSDefaultDir' referenced before
>assignment
> r.append(str(SSDefaultDir))
> SSDefaultDir=SessionDir
> f=open("c:/now.txt","a")
> f.write(" "+SSDefaultDir)
> f.close()
> finally:
> SSUnlock()
>
>--------------
>
>When I not use SSInit, only I write the global variable in BHASession
>module like this:
>
>SSDefaultDir="c:/bhaweb/sessions"
>
>then it is working good !!!
>
>Why ? How to force python to module see his variable ?
>
>Thanx for any advance !
>
>--
>Best regards,
> fowlertrainer mailto:fowlertrainer at anonym.hu
>
>_______________________________________________
>Mod_python mailing list
>Mod_python at modpython.org
>http://mailman.modpython.org/mailman/listinfo/mod_python
|