Works with python2.4.
This commit is contained in:
parent
136b94cc24
commit
191e642b22
|
@ -194,7 +194,7 @@ class Application(applications.Application):
|
|||
_req = req._req
|
||||
except AttributeError:
|
||||
_req = req
|
||||
|
||||
|
||||
# If the file at webFilePath exists and is static (images,
|
||||
# stylesheets...) then return its content directly.
|
||||
if not (_req.filename.endswith('/index') or
|
||||
|
@ -621,7 +621,7 @@ class Application(applications.Application):
|
|||
|
||||
if reqCache is None:
|
||||
# The system caching is not activated when a session is open.
|
||||
reqCache = Request(req)
|
||||
reqCache = req
|
||||
reqCache.caching = 0
|
||||
reqCache.depends = []
|
||||
reqCache.buffered = 0
|
||||
|
@ -1066,7 +1066,7 @@ class Application(applications.Application):
|
|||
else:
|
||||
module = apache.import_module(
|
||||
moduleName,
|
||||
context.getVar('req')._req,
|
||||
context.getVar('req'),
|
||||
context.getVar('webDirectoryPaths'))
|
||||
except ImportError:
|
||||
if context.getVar('debug'):
|
||||
|
@ -1314,11 +1314,6 @@ class BufferedRequest:
|
|||
except AttributeError:
|
||||
self.__dict__[attr] = val
|
||||
|
||||
class Request(apache.Request):
|
||||
def write(self, st):
|
||||
if type(st) is type(u''):
|
||||
st = st.encode('iso-8859-1')
|
||||
return self._req.write(st)
|
||||
|
||||
class RequestCache:
|
||||
buffered = 0
|
||||
|
@ -1332,8 +1327,12 @@ class RequestCache:
|
|||
depends = None
|
||||
|
||||
def __init__(self, req, language):
|
||||
for key, value in req.__dict__.items():
|
||||
self.__dict__[key] = value
|
||||
for attr in dir(req):
|
||||
if hasattr(req, attr) and not attr.startswith('_'): #and type(getattr(req, attr))!=type(str) :
|
||||
try:
|
||||
setattr(self, attr, getattr(req, attr))
|
||||
except:
|
||||
pass
|
||||
self.cacheDirectoryPath = os.path.join(
|
||||
context.getVar('varDirectoryPath'), 'webcache',
|
||||
context.getVar('virtualHost').hostName)
|
||||
|
@ -1353,7 +1352,12 @@ class RequestCache:
|
|||
self.cacheDirectoryPath,
|
||||
self.getCacheFileName(language) + '.mimetype')
|
||||
self.depends = []
|
||||
|
||||
if not self.__dict__.has_key('_req') or not self.__dict__[_req_]:
|
||||
try:
|
||||
self._req = req._req
|
||||
except:
|
||||
self._req = req
|
||||
|
||||
def cancel(self):
|
||||
if self.cacheFile is not None:
|
||||
self.cacheFile.close()
|
||||
|
@ -1451,12 +1455,20 @@ class RequestCache:
|
|||
fcntl.lockf(self.cacheFile, fcntl.LOCK_UN)
|
||||
|
||||
def __getattr__(self, attr):
|
||||
if not hasattr(self, '_req'):
|
||||
try:
|
||||
return self.__dict__[attr]
|
||||
except AttributeError:
|
||||
raise AttributeError, attr
|
||||
try:
|
||||
return getattr(self._req, attr)
|
||||
except AttributeError:
|
||||
raise AttributeError, attr
|
||||
|
||||
def __setattr__(self, attr, val):
|
||||
if not hasattr(self, '_req'):
|
||||
self.__dict__[attr] = val
|
||||
return
|
||||
try:
|
||||
if attr != '_req':
|
||||
setattr(self._req, attr, val)
|
||||
|
|
Reference in New Issue