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