Volodya
volodya at real.samuraj.org
Mon May 17 16:28:20 EDT 2004
On Mon, May 17, 2004 at 11:51:55AM +0300, Fabian Fagerholm wrote: > On Mon, 2004-05-17 at 11:11, Volodya wrote: > > > File "/usr/lib/python2.3/site-packages/mod_python/psp.py", line 114, in __init__ > > > cached = strcache.get(string) > > > > > > NameError: global name 'strcache' is not defined > > > > > > Looking at psp.py, indeed I can't seem to find any place where the > > > strcache variable would be initialized. > > > > > > Any hints? > > > > http://www.modpython.org/pipermail/mod_python/2004-May/015552.html > > Replacing strcache with mem_scache just locks up the application. The > same thing does appear to happen if I use the following in a file: > > <div>.</div> > > (with newline at the end) > > Any more ideas? > Quick & dirty hack: In psp.py , PSP.__init__ : # --------------------------------------------------------------- if filename: # if filename is not absolute, default to our guess # of current directory if not os.path.isabs(filename): base = os.path.split(req.filename)[0] self.filename = os.path.join(base, filename) self.load_from_file() else: #cached = strcache.get(string) #if cached: # self.code = cached #else: # strcache.store(string) # !!! HACK !!! parsed = _psp.parsestring(string) self.code = compile(parsed,"<string>","exec") # --------------------------------------------------------------- 1. Original (broken) caching code is commented 2. Added compile call tested on: # -- test.py --------------------------------------------------- from mod_python import apache, psp psp_string = """ <html><body> <% for i in range(5): req.write("Hello<br/>"); #endif %> </body></html> """ def handler(req): psp_object = psp.PSP(req, string = psp_string) req.write(str(psp_object)) return apache.OK # -- end of test.py -------------------------------------------- Hope this helps.
|