本文整理汇总了Python中collective.cover.tiles.base.IPersistentCoverTile类的典型用法代码示例。如果您正苦于以下问题:Python IPersistentCoverTile类的具体用法?Python IPersistentCoverTile怎么用?Python IPersistentCoverTile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IPersistentCoverTile类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_interface
def test_interface(self):
self.assertTrue(IPersistentCoverTile.implementedBy(ListFolderContentsTile))
self.assertTrue(verifyClass(IPersistentCoverTile, ListFolderContentsTile))
tile = ListFolderContentsTile(None, None)
self.assertTrue(IPersistentCoverTile.providedBy(tile))
self.assertTrue(verifyObject(IPersistentCoverTile, tile))
示例2: test_interface
def test_interface(self):
self.assertTrue(IPersistentCoverTile.implementedBy(CarouselTile))
self.assertTrue(verifyClass(IPersistentCoverTile, CarouselTile))
tile = CarouselTile(None, None)
self.assertTrue(IPersistentCoverTile.providedBy(tile))
self.assertTrue(verifyObject(IPersistentCoverTile, tile))
示例3: test_interface
def test_interface(self):
self.assertTrue(IPersistentCoverTile.implementedBy(PhotoGalleryTile))
self.assertTrue(verifyClass(IPersistentCoverTile, PhotoGalleryTile))
tile = PhotoGalleryTile(None, None)
self.assertTrue(IPersistentCoverTile.providedBy(tile))
self.assertTrue(verifyObject(IPersistentCoverTile, tile))
示例4: test_interface
def test_interface(self):
self.assertTrue(IPersistentCoverTile.implementedBy(BannerTile))
self.assertTrue(verifyClass(IPersistentCoverTile, BannerTile))
tile = BannerTile(None, None)
self.assertTrue(IPersistentCoverTile.providedBy(tile))
# FIXME: @property decorator on class methods makes this test fail
# how can we fix it?
self.assertTrue(verifyObject(IPersistentCoverTile, tile))
示例5: test_interface
def test_interface(self):
self.assertTrue(IPersistentCoverTile.implementedBy(PersistentCoverTile))
self.assertTrue(verifyClass(IPersistentCoverTile, PersistentCoverTile))
# cover tiles inherit from plone.tile PersistentTile
self.assertTrue(IPersistentTile.implementedBy(PersistentCoverTile))
tile = PersistentCoverTile(None, None)
self.assertTrue(IPersistentCoverTile.providedBy(tile))
self.assertTrue(verifyObject(IPersistentCoverTile, tile))
# cover tiles inherit from plone.tile PersistentTile
self.assertTrue(IPersistentTile.providedBy(tile))
示例6: scale
def scale(self, fieldname=None, scale=None,
height=None, width=None, **parameters):
if not IPersistentCoverTile.providedBy(self.context):
base_scales = queryMultiAdapter((self.context, self.request),
name='images',
default=None)
if base_scales:
try:
scale = base_scales.scale(fieldname,
scale,
height,
width,
**parameters)
except AttributeError:
scale = None
return scale
else:
return None
if fieldname is None:
fieldname = IPrimaryFieldInfo(self.context).fieldname
if scale is not None:
available = self.getAvailableSizes(fieldname)
if scale not in available:
return None
width, height = available[scale]
storage = AnnotationStorage(self.context, self.modified)
info = storage.scale(factory=self.create,
fieldname=fieldname,
height=height,
width=width,
**parameters)
if info is not None:
info['fieldname'] = fieldname
scale_view = ImageScale(self.context, self.request, **info)
return scale_view.__of__(self.context)
示例7: modified
def modified(self):
""" provide a callable to return the modification time of content
items, so stored image scales can be invalidated """
if not IPersistentCoverTile.providedBy(self.context):
base_scales = queryMultiAdapter((self.context, self.request),
name='images',
default=None)
return base_scales and base_scales.modified()
mtime = None
for k, v in self.context.data.items():
if INamedImage.providedBy(v):
mtime = self.context.data.get('{0}_mtime'.format(k), None)
return mtime
示例8: create
def create(self, fieldname, direction='thumbnail',
height=None, width=None, **parameters):
""" factory for image scales, see `IImageScaleStorage.scale` """
if not IPersistentCoverTile.providedBy(self.context):
base_scales = queryMultiAdapter((self.context, self.request),
name='images', default=None)
return base_scales and base_scales.create(fieldname,
direction,
height,
width,
**parameters)
orig_value = self.context.data.get(fieldname)
if orig_value is None:
return
if height is None and width is None:
_, format = orig_value.contentType.split('/', 1)
return None, format, (orig_value._width, orig_value._height)
if safe_hasattr(aq_base(orig_value), 'open'):
orig_data = orig_value.open()
else:
orig_data = getattr(aq_base(orig_value), 'data', orig_value)
if not orig_data:
return
try:
result = scaleImage(orig_data, direction=direction,
height=height, width=width, **parameters)
except (ConflictError, KeyboardInterrupt):
raise
except Exception: # FIXME: B901 blind except: statement
logging.exception(
'could not scale "{0}" of {1}'.format(
repr(orig_value),
repr(self.context.context.absolute_url())))
return
if result is not None:
data, format_, dimensions = result
mimetype = 'image/' + format_.lower()
value = orig_value.__class__(data, contentType=mimetype,
filename=orig_value.filename)
value.fieldname = fieldname
return value, format_, dimensions
示例9: _enabled
def _enabled(self, name):
tile = getMultiAdapter((self.context, self.request), name=name)
return IPersistentCoverTile.providedBy(tile)
示例10: test_interface
def test_interface(self):
self.assertTrue(IPersistentCoverTile.implementedBy(BannerTile))
self.assertTrue(verifyClass(IPersistentCoverTile, BannerTile))
tile = BannerTile(None, None)
self.assertTrue(IPersistentCoverTile.providedBy(tile))
示例11: test_interface
def test_interface(self):
self.assertTrue(IPersistentCoverTile.implementedBy(ICarrosselTile))