def available(self): context = self.context if INavigationRoot.providedBy(context.__parent__) and not(IATUnifiedFolder.providedBy(context)): # Product is not installed return True else: return False
def get_coverimage(self): """ if set imagescollection on PDF Theme, return a random image, None otherwise """ imgview = queryMultiAdapter((self.context, self.request), name='imgview') if imgview and imgview.display(): obj = imgview('large') # 83520 cover should be an object not image string data if isinstance(obj, str): return getattr(imgview, 'context', None) return obj theme = self.get_pdftheme() if not theme: return None container = theme.getImagescollection() if not container: return None results = None if IATUnifiedFolder.providedBy(container): # container is a folder cur_path = '/'.join(container.getPhysicalPath()) path = {'query': cur_path, 'depth': 1} results = container.portal_catalog(**{ 'portal_type': 'Image', 'path': path }) else: # is a container results = container.queryCatalog(sort_on=None, batch=False) if results is None: return None return random.sample(results, 1)[0].getObject()
def get_coverimage(self): """ if set imagescollection on PDF Theme, return a random image, None otherwise """ imgview = queryMultiAdapter( (self.context, self.request), name='imgview') if imgview and imgview.display(): obj = imgview('large') # 83520 cover should be an object not image string data if isinstance(obj, str): return getattr(imgview, 'context', None) return obj theme = self.get_pdftheme() if not theme: return None container = theme.getImagescollection() if not container: return None results = None if IATUnifiedFolder.providedBy(container): # container is a folder cur_path = '/'.join(container.getPhysicalPath()) path = {'query': cur_path, 'depth': 1} results = container.portal_catalog( **{'portal_type': 'Image', 'path': path} ) else: # is a container results = container.queryCatalog(sort_on=None, batch=False) if results is None: return None return random.sample(results, 1)[0].getObject()
def test_IATUnifiedFolder(self): assert IATUnifiedFolder.providedBy(self.book)
def unavailable_to_make_microsite(self): return IATUnifiedFolder.providedBy(self.context) and INavigationRoot.providedBy(self.context)
def available_to_make_microsite(self): return IATUnifiedFolder.providedBy( self.context) and not INavigationRoot.providedBy(self.context)