def hasImageAndCaption(object, portal, **kw): """This indexable attribute is made to avoid the awakening of the object while needing to know if the supposedly attached image exists or not. It's very useful for the summary views or other kind of listings. """ object = aq_base(object) if not IImageContent.providedBy(object): adapted = IImageContentProvider(object, None) if adapted is None: return None else: sub_path = adapted.sub_path thumb_path = adapted.thumb_path image = adapted.getImage() else: sub_path = "image" thumb_path = "image_" image = object.getImage() if image: caption = getattr(object, "getImageCaption", None) return { 'image': True, 'sub_path': sub_path, 'thumb_path': thumb_path, 'caption': caption and caption() or None } return {'image': False, 'caption': None, 'thumb_path': None, 'sub_path': None}
def __call__(self, context): type_values = registered_types.values() impl_image = lambda x : IImageContent.implementedBy(x['klass']) image_types = [v['klass'].portal_type for v in type_values if impl_image(v)] # remove duplicates when several types have the same content type # even if they are not installed at the same time _image_types = [] [_image_types.append(i) for i in image_types if image_types.count(i) == 1] items = [SimpleTerm(i, i , i) for i in _image_types] return SimpleVocabulary(items)
def __call__(self, context): type_values = registered_types.values() impl_image = lambda x: IImageContent.implementedBy(x['klass']) image_types = [ v['klass'].portal_type for v in type_values if impl_image(v) ] # remove duplicates when several types have the same content type # even if they are not installed at the same time _image_types = [] [ _image_types.append(i) for i in image_types if image_types.count(i) == 1 ] items = [SimpleTerm(i, i, i) for i in _image_types] return SimpleVocabulary(items)
def should_include(self, request): pm = getToolByName(self.context, 'portal_membership') return IImageContent.providedBy(self.context) and \ not pm.isAnonymousUser() and \ '/@@imageeditor.' in request.get('ACTUAL_URL')
def editable(self): pm = getToolByName(self.context, 'portal_membership') return IImageContent.providedBy(self.context) and not \ pm.isAnonymousUser()