本文整理匯總了Python中OFS.Image.File.manage_upload方法的典型用法代碼示例。如果您正苦於以下問題:Python File.manage_upload方法的具體用法?Python File.manage_upload怎麽用?Python File.manage_upload使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OFS.Image.File
的用法示例。
在下文中一共展示了File.manage_upload方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: manage_upload
# 需要導入模塊: from OFS.Image import File [as 別名]
# 或者: from OFS.Image.File import manage_upload [as 別名]
def manage_upload(self, file=None, REQUEST=None) :
""" Zope calls this when the content of the enclosed file changes.
The 'cells' attribute is updated, but already defined cells are not
erased, they are saved in the 'all_cells' attribute so if the pdf
file is reverted, you do not loose the cells definitions.
"""
if not file or not hasattr(file, "read") :
raise ValueError ("The pdf form file should not be empty")
file.seek(0) # file is always valid here
values = PDFTk().dumpDataFields(file)
self.cells = {}
for v in values :
if v["FieldType"] not in ("Button", "Choice")\
or not int(v["FieldFlags"]) & 65536:
k = v["FieldName"]
if not self.all_cells.has_key(k) :
self.cells[k] = ""
else :
self.cells[k] = self.all_cells[k]
self.all_cells.update(self.cells)
file.seek(0)
File.manage_upload(self, file, REQUEST)
if REQUEST:
message = "Saved changes."
return self.manage_main(self, REQUEST, manage_tabs_message=message)
示例2: manage_upload
# 需要導入模塊: from OFS.Image import File [as 別名]
# 或者: from OFS.Image.File import manage_upload [as 別名]
def manage_upload( self, file='', REQUEST=None ):
""" This overrided the manage_upload provided by the File class
to add a hook for setting the original filename.
"""
LOG('XWFPluggableFile1.1',INFO,str(dir(file)))
File.manage_upload( self, file )
filename = getattr( file, 'filename', '' )
filename = convertTextToAscii( removePathsFromFilenames( filename ) )
self.filename = filename
self.manage_changeProperties(original_filename=filename)\
if REQUEST:
message="Saved changes."
return self.manage_main( self, REQUEST, manage_tabs_message=message )