本文整理汇总了Python中OFS.Image.File.index_html方法的典型用法代码示例。如果您正苦于以下问题:Python File.index_html方法的具体用法?Python File.index_html怎么用?Python File.index_html使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OFS.Image.File
的用法示例。
在下文中一共展示了File.index_html方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: viewOriginal
# 需要导入模块: from OFS.Image import File [as 别名]
# 或者: from OFS.Image.File import index_html [as 别名]
def viewOriginal(self, REQUEST=None, RESPONSE=None, *args, **kwargs) :
""" publish original pdf """
pdf = File.index_html(self, REQUEST, RESPONSE, *args, **kwargs)
RESPONSE.setHeader('Content-Type', 'application/pdf')
RESPONSE.setHeader('Content-Disposition', 'inline;filename="%s.pdf"'
% (self.title_or_id()))
return pdf
示例2: index_html
# 需要导入模块: from OFS.Image import File [as 别名]
# 或者: from OFS.Image.File import index_html [as 别名]
def index_html( self, REQUEST, RESPONSE ):
""" Extends the file index_html to set the download filename.
"""
filename = self.get_filename()
REQUEST.RESPONSE.setHeader( 'Content-Disposition',
'inline; filename="%s"' % filename )
return File.index_html( self, REQUEST, RESPONSE )
示例3: index_html
# 需要导入模块: from OFS.Image import File [as 别名]
# 或者: from OFS.Image.File import index_html [as 别名]
def index_html(self, REQUEST, RESPONSE):
""" Override for File.index_html
"""
# this is to deal with an acquisition issue, where
# the context gets lost when .data is called
bfd = self.get_baseFilesDir()
if self._base_files_dir != bfd:
self._base_files_dir = bfd
return File.index_html(self, REQUEST, RESPONSE)
示例4: some
# 需要导入模块: from OFS.Image import File [as 别名]
# 或者: from OFS.Image.File import index_html [as 别名]
renderer = appy.pod.renderer.Renderer(**rendererParams)
renderer.run()
except appy.pod.PodError, pe:
if not os.path.exists(tempFileName):
# In some (most?) cases, when OO returns an error, the result is
# nevertheless generated.
raise PloneMeetingError(POD_ERROR % str(pe))
# Open the temp file on the filesystem
f = file(tempFileName, 'rb')
if forBrowser:
# Create a OFS.Image.File object that will manage correclty HTTP
# headers, etc.
from OFS.Image import File
theFile = File('dummyId', 'dummyTitle', f,
content_type=mimeTypes[self.getPodFormat()])
res = theFile.index_html(self.REQUEST, self.REQUEST.RESPONSE)
# Before, I used the code below to set the HTTP headers.
# But I've noticed that with some browsers (guess which one?) the
# returned document could not be opened. Worse: the browser crashed
# completely in some cases. So now I rely on File.index_html
# instead. One caveat: the title of the file is "generateDocument-X'
# and not a friendly title as before...
#response = obj.REQUEST.RESPONSE
#response.setHeader('Content-type', mimeTypes[self.getPodFormat()])
#response.setHeader('Content-disposition',
# 'inline;filename="%s.%s"' % (
# obj.Title(), self.getPodFormat()))
else:
# I must return the raw document content.
res = f.read()
f.close()