Commit 3e22e015 authored by Aurel's avatar Aurel

make non compressed call work

propagate the compressed parameter everywhere
update docstring


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37750 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 65c6a6b9
...@@ -120,7 +120,7 @@ class IntrospectionTool(LogMixin, BaseTool): ...@@ -120,7 +120,7 @@ class IntrospectionTool(LogMixin, BaseTool):
def _getLocalFile(self, REQUEST, RESPONSE, file_path, def _getLocalFile(self, REQUEST, RESPONSE, file_path,
tmp_file_path='/tmp/', compressed=1): tmp_file_path='/tmp/', compressed=1):
""" """
It should return the local file compacted as tar.gz. It should return the local file compacted or not as tar.gz.
""" """
if file_path.startswith('/'): if file_path.startswith('/'):
raise IOError, 'The file path must be relative not absolute' raise IOError, 'The file path must be relative not absolute'
...@@ -135,14 +135,19 @@ class IntrospectionTool(LogMixin, BaseTool): ...@@ -135,14 +135,19 @@ class IntrospectionTool(LogMixin, BaseTool):
tmp_file.add(file_path) tmp_file.add(file_path)
tmp_file.close() tmp_file.close()
RESPONSE.setHeader('Content-type', 'application/x-tar') RESPONSE.setHeader('Content-type', 'application/x-tar')
RESPONSE.setHeader('Content-Disposition', \
'attachment;filename="%s.tar.gz"' % file_path.split('/')[-1])
else: else:
RESPONSE.setHeader('Content-type', 'application/txt')
RESPONSE.setHeader('Content-Disposition', \
'attachment;filename="%s.txt"' % file_path.split('/')[-1])
tmp_file_path = file_path tmp_file_path = file_path
f = open(tmp_file_path) f = open(tmp_file_path)
try: try:
RESPONSE.setHeader('Content-Length', os.stat(tmp_file_path).st_size) RESPONSE.setHeader('Content-Length', os.stat(tmp_file_path).st_size)
RESPONSE.setHeader('Content-Disposition', \
'attachment;filename="%s.tar.gz"' % file_path.split('/')[-1])
for data in f: for data in f:
RESPONSE.write(data) RESPONSE.write(data)
finally: finally:
...@@ -170,7 +175,7 @@ class IntrospectionTool(LogMixin, BaseTool): ...@@ -170,7 +175,7 @@ class IntrospectionTool(LogMixin, BaseTool):
security.declareProtected(Permissions.ManagePortal, 'getAccessLog') security.declareProtected(Permissions.ManagePortal, 'getAccessLog')
def getEventLog(self, compressed=1, REQUEST=None): def getEventLog(self, compressed=1, REQUEST=None):
""" """
Get the Access Log. Get the Event Log.
""" """
if REQUEST is not None: if REQUEST is not None:
response = REQUEST.RESPONSE response = REQUEST.RESPONSE
...@@ -184,7 +189,7 @@ class IntrospectionTool(LogMixin, BaseTool): ...@@ -184,7 +189,7 @@ class IntrospectionTool(LogMixin, BaseTool):
security.declareProtected(Permissions.ManagePortal, 'getAccessLog') security.declareProtected(Permissions.ManagePortal, 'getAccessLog')
def getDataFs(self, compressed=1, REQUEST=None): def getDataFs(self, compressed=1, REQUEST=None):
""" """
Get the Access Log. Get the Data.fs.
""" """
if REQUEST is not None: if REQUEST is not None:
response = REQUEST.RESPONSE response = REQUEST.RESPONSE
...@@ -193,7 +198,7 @@ class IntrospectionTool(LogMixin, BaseTool): ...@@ -193,7 +198,7 @@ class IntrospectionTool(LogMixin, BaseTool):
return self._getLocalFile(REQUEST, response, return self._getLocalFile(REQUEST, response,
file_path='var/Data.fs', file_path='var/Data.fs',
compressed=1) compressed=compressed)
# #
# Instance variable definition access # Instance variable definition access
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment