当前位置: 首页>>代码示例>>Python>>正文


Python Image.File类代码示例

本文整理汇总了Python中OFS.Image.File的典型用法代码示例。如果您正苦于以下问题:Python File类的具体用法?Python File怎么用?Python File使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了File类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: manage_upload

  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)
开发者ID:Provab-Solutions,项目名称:erp5,代码行数:26,代码来源:PDFForm.py

示例2: __setstate__

 def __setstate__(self, dict):
     mimetype = dict.get('mimetype', None)
     if IMimetype.isImplementedBy(mimetype):
         dict['mimetype'] = str(mimetype)
         dict['binary'] = not not mimetype.binary
     assert(dict.has_key('mimetype'), 'no mimetype in setstate dict')
     File.__setstate__(self, dict)
开发者ID:dtgit,项目名称:dtedu,代码行数:7,代码来源:BaseUnit.py

示例3: manage_afterAdd

 def manage_afterAdd( self, item, container ):
     """ For cleaning up as we are removed.
     
     """
     File.manage_afterAdd( self, item, container )
     if IXWFFileReader.isImplementedBy( self.storage_plugin ):
         self.storage_plugin.set_physicalPath( self.getPhysicalPath() )
     XWFCatalogAware.manage_afterAdd( self, item, container )
开发者ID:groupserver,项目名称:Products.XWFPluggableFiles,代码行数:8,代码来源:XWFPluggableFile.py

示例4: manage_beforeDelete

 def manage_beforeDelete( self, item, container ):
     """ For cleaning up as we are removed.
     
     """
     if IXWFFileReader.isImplementedBy( self.storage_plugin ):
         self.storage_plugin.set_physicalPath( None )
     XWFCatalogAware.manage_beforeDelete( self, item, container )
     File.manage_beforeDelete( self, item, container )
开发者ID:groupserver,项目名称:Products.XWFPluggableFiles,代码行数:8,代码来源:XWFPluggableFile.py

示例5: __init__

  def __init__ (self, id, title='', pdf_file=''):
    # holds all the cell informations, even those not related to this form
    self.all_cells = PersistentMapping()
    # holds the cells related to this pdf form
    self.cells = PersistentMapping()

    # File constructor will set the file content
    File.__init__(self, id, title, pdf_file)
开发者ID:Provab-Solutions,项目名称:erp5,代码行数:8,代码来源:PDFForm.py

示例6: __init__

    def __init__(self, id):
        """ Initialise a new instance of XWFFile.

        """
        self.id = id
        self.initProperties()
        File.__init__(self, id, id, '', '', '')
        self.update_data('', '', 0)
开发者ID:groupserver,项目名称:Products.XWFFileLibrary2,代码行数:8,代码来源:XWFFile2.py

示例7: manage_afterClone

 def manage_afterClone( self, item ):
     """ For configuring the object post copy.
     
     """
     File.manage_afterClone( self, item )
     if IXWFFileReader.isImplementedBy( self.storage_plugin ):
         self.storage_plugin.set_physicalPath( self.getPhysicalPath() )
     XWFCatalogAware.manage_afterClone( self, item )
开发者ID:groupserver,项目名称:Products.XWFPluggableFiles,代码行数:8,代码来源:XWFPluggableFile.py

示例8: testBlobbableOFSFile

 def testBlobbableOFSFile(self):
     obj = File('foo', 'Foo', getFile('plone.pdf'), 'application/pdf')
     obj.filename = 'foo.pdf'
     blobbable = IBlobbable(obj)
     target = Blob()
     blobbable.feed(target)
     self.assertEqual(target.open('r').read(),
         getFile('plone.pdf').read())
     self.assertEqual(blobbable.filename(), 'foo.pdf')
     self.assertEqual(blobbable.mimetype(), 'application/pdf')
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:10,代码来源:test_adapters.py

示例9: __init__

 def __init__( self, id, storage_plugin ):
     """ Initialise a new instance of XWFPluggableFile.
         
     """
     self.storage_plugin = storage_plugin()
     # we do a quick, fake, init here, and do the actual file
     # later
     File.__init__( self, id, id, '' )
     
     security = getSecurityManager()
     self.manage_addProperty( 'dc_creator', security.getUser().getId(), 'ustring' )
     self.manage_addProperty( 'original_filename', '', 'ustring' )
开发者ID:groupserver,项目名称:Products.XWFPluggableFiles,代码行数:12,代码来源:XWFPluggableFile.py

示例10: _copyFile

def _copyFile(f_from, f_to, id, keep_new=False):
  obj_id = id
  if hasattr(f_to,id):
    if keep_new:
      obj_id = 'old_' + id
    else:
      _renameObj (f_to, id, 'new_' + id)
  oldobj = f_from._getOb(id)
  newobj = File(obj_id,oldobj.title,'',oldobj.content_type)
  newobj.size = oldobj.size
  newobj.data = oldobj.data[:]
  f_to._setObject(obj_id, newobj)
开发者ID:,项目名称:,代码行数:12,代码来源:

示例11: writeFile

 def writeFile(self, path, data):
     basepath = '/'.join(path.split('/')[:-1])
     if basepath:
         self.makeDirectory(basepath)
     filename = path.split('/')[-1]
     if isinstance(filename, unicode):
         filename = filename.encode('utf-8')
     f = File(filename, filename, data)
     if f.getContentType() == 'text/html':
         # otherwise HTTPResponse.setBody assumes latin1 and mangles things
         f.content_type = 'text/html; charset=utf-8'
     container = self.context.unrestrictedTraverse(basepath)
     if filename in container:
         container._delOb(filename)
     container._setOb(filename, f)
开发者ID:Vinsurya,项目名称:Plone,代码行数:15,代码来源:directory.py

示例12: viewOriginal

 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
开发者ID:Provab-Solutions,项目名称:erp5,代码行数:7,代码来源:PDFForm.py

示例13: test_OFSFileLastModified_File

 def test_OFSFileLastModified_File(self):
     from OFS.Image import File
     
     dummy = File('dummy', 'Dummy', 'data')
     self.assertEquals(None, ILastModified(dummy)())
     
     timestamp = 987654321.0 # time stamp (in UTC)
     ts = TimeStamp(*time.gmtime(timestamp)[:6]) # corresponding TimeStamp
     
     # equivalent in local time, which is what the last-modified adapter
     # should return
     mod = datetime.datetime.fromtimestamp(timestamp, tzlocal())
     
     dummy._p_jar = FauxDataManager()
     dummy._p_serial = repr(ts)
     self.assertEquals(mod, ILastModified(dummy)())
开发者ID:,项目名称:,代码行数:16,代码来源:

示例14: manage_upload

 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 )
开发者ID:groupserver,项目名称:Products.XWFPluggableFiles,代码行数:17,代码来源:XWFPluggableFile.py

示例15: index_html

 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 )
开发者ID:groupserver,项目名称:Products.XWFPluggableFiles,代码行数:9,代码来源:XWFPluggableFile.py


注:本文中的OFS.Image.File类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。