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


Python IBlobbable.filename方法代码示例

本文整理汇总了Python中plone.app.blob.interfaces.IBlobbable.filename方法的典型用法代码示例。如果您正苦于以下问题:Python IBlobbable.filename方法的具体用法?Python IBlobbable.filename怎么用?Python IBlobbable.filename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在plone.app.blob.interfaces.IBlobbable的用法示例。


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

示例1: set

# 需要导入模块: from plone.app.blob.interfaces import IBlobbable [as 别名]
# 或者: from plone.app.blob.interfaces.IBlobbable import filename [as 别名]
 def set(self, instance, value, **kwargs):
     """ use input value to populate the blob and set the associated
         file name and mimetype.  the latter can be overridden by an
         option "mimetype" keyword argument """
     if value in ('DELETE_FILE', 'DELETE_IMAGE'):
         super(BlobField, self).unset(instance, **kwargs)
         return
     # create a new blob instead of modifying the old one to
     # achieve copy-on-write semantics
     blob = BlobWrapper(self.default_content_type)
     if isinstance(value, basestring):
         value = StringIO(value)     # simple strings cannot be adapted...
         setattr(value, 'filename', kwargs.get('filename', None))
     if value is not None:
         blobbable = IBlobbable(value)
         try:
             blobbable.feed(blob.getBlob())
         except ReuseBlob, exception:
             blob.setBlob(exception.args[0])     # reuse the given blob
         mimetype = kwargs.get('mimetype', None)
         if not mimetype:
             mimetype = blobbable.mimetype()
         if mimetype and mimetype != 'None':
             blob.setContentType(mimetype)
         blob.setFilename(kwargs.get('filename', blobbable.filename()))
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:27,代码来源:field.py

示例2: testBlobbableOFSFileWithoutFileName

# 需要导入模块: from plone.app.blob.interfaces import IBlobbable [as 别名]
# 或者: from plone.app.blob.interfaces.IBlobbable import filename [as 别名]
 def testBlobbableOFSFileWithoutFileName(self):
     obj = File('foo', 'Foo', getFile('plone.pdf'), 'application/pdf')
     blobbable = IBlobbable(obj)
     target = Blob()
     blobbable.feed(target)
     self.assertEqual(target.open('r').read(),
         getFile('plone.pdf').read())
     self.assertEqual(blobbable.filename(), '')
     self.assertEqual(blobbable.mimetype(), 'application/pdf')
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:11,代码来源:test_adapters.py

示例3: testBlobbableOFSImage

# 需要导入模块: from plone.app.blob.interfaces import IBlobbable [as 别名]
# 或者: from plone.app.blob.interfaces.IBlobbable import filename [as 别名]
 def testBlobbableOFSImage(self):
     gif = getImage()
     obj = Image('foo', 'Foo', StringIO(gif))
     obj.filename = 'foo.gif'
     blobbable = IBlobbable(obj)
     target = Blob()
     blobbable.feed(target)
     self.assertEqual(target.open('r').read(), gif)
     self.assertEqual(blobbable.filename(), 'foo.gif')
     self.assertEqual(blobbable.mimetype(), 'image/gif')
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:12,代码来源:test_adapters.py

示例4: testBlobbableBinaryFile

# 需要导入模块: from plone.app.blob.interfaces import IBlobbable [as 别名]
# 或者: from plone.app.blob.interfaces.IBlobbable import filename [as 别名]
 def testBlobbableBinaryFile(self):
     _file = os.path.join(os.path.dirname(__file__), 'data', 'image.gif')
     with open(_file, 'rb') as f:
         obj = Binary(f)
         obj.filename = 'image.gif'
         blobbable = IBlobbable(obj)
         target = Blob()
         blobbable.feed(target)
         self.assertEqual(target.open('r').read(),
                          getFile('image.gif').read())
         self.assertEquals(blobbable.filename(), 'image.gif')
         self.assertEquals(blobbable.mimetype(), 'image/gif')
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:14,代码来源:test_adapters.py

示例5: set

# 需要导入模块: from plone.app.blob.interfaces import IBlobbable [as 别名]
# 或者: from plone.app.blob.interfaces.IBlobbable import filename [as 别名]
    def set(self, instance, value, **kwargs):
        """ use input value to populate the blob and set the associated
            file name and mimetype """
        if value == "DELETE_FILE":
            ObjectField.unset(self, instance, **kwargs)
            return
        # create a new blob instead of modifying the old one to
        # achieve copy-on-write semantics.

        if isinstance(value, basestring):
            # make StringIO from string, because StringIO may be adapted to Blobabble
            value = StringIO(value)
        if value is not None:
            blobbable = IBlobbable(value)
            #move blob ctor down to where we know the mimetype
            blob = BlobWrapper(blobbable.mimetype())
            blobbable.feed(blob.getBlob())
            blob.setContentType(blobbable.mimetype())
            
            blob.setFilename(blobbable.filename())
        ObjectField.set(self, instance, blob, **kwargs)
        self.fixAutoId(instance)
开发者ID:collective,项目名称:collective.psc.blobstorage,代码行数:24,代码来源:__init__.py


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