本文整理汇总了Python中twisted.web.static.File.isLeaf方法的典型用法代码示例。如果您正苦于以下问题:Python File.isLeaf方法的具体用法?Python File.isLeaf怎么用?Python File.isLeaf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.web.static.File
的用法示例。
在下文中一共展示了File.isLeaf方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: download_zip
# 需要导入模块: from twisted.web.static import File [as 别名]
# 或者: from twisted.web.static.File import isLeaf [as 别名]
def download_zip(self, request, request_id):
download = yield self.download_database.get_download(
self.logger, request_id=request_id
)
assert download.completed
self.logger.bind(
request_id=request_id,
file_number=download.file_number,
).emit("download")
document_types = yield self.document_types.wait()
path = download.build_zip(self.jinja_env, self.fernet, document_types)
request.setHeader(
"Content-Disposition",
"attachment; filename={}-eFolder.zip".format(download.file_number)
)
resource = File(path, defaultType="application/zip")
resource.isLeaf = True
request.notifyFinish().addBoth(lambda *args, **kwargs: os.remove(path))
returnValue(resource)
示例2: getChild
# 需要导入模块: from twisted.web.static import File [as 别名]
# 或者: from twisted.web.static.File import isLeaf [as 别名]
def getChild(self, name, request):
#make source media available via oshash
if request.path.startswith('/get/'):
oshash = request.path.split('/')[-1]
for path in self.client.path(oshash):
if os.path.exists(path):
f = File(path, 'application/octet-stream')
f.isLeaf = True
return f
return self
示例3: getFile
# 需要导入模块: from twisted.web.static import File [as 别名]
# 或者: from twisted.web.static.File import isLeaf [as 别名]
def getFile(self, request, transferId, *args):
"""
Get the file objects located at transfer id.
"""
transfer = self._outboundRequests.get(transferId)
if transfer is None:
return NoResource()
rootpath = filepath.FilePath(transfer.filenameBytes())
if rootpath.isdir():
return File(rootpath.dirname())
if rootpath.isfile():
file = File(rootpath.path)
file.isLeaf = True
return file
示例4: static
# 需要导入模块: from twisted.web.static import File [as 别名]
# 或者: from twisted.web.static.File import isLeaf [as 别名]
def static(request):
file = File("./staticfile.txt")
file.isLeaf = True
return file
示例5: index
# 需要导入模块: from twisted.web.static import File [as 别名]
# 或者: from twisted.web.static.File import isLeaf [as 别名]
def index(_):
index_path = os.path.join(self.root_path, 'templates', 'index.html')
print index_path
f = File(index_path)
f.isLeaf = True
return f