def walk(items, result, parent): for item in items: collection = [] if COLLECTION and IContentListingObject.providedBy(item): item = item.getObject() elif IATTopic.providedBy(item): collection = item.queryCatalog(b_size=100, full_objects=True) elif COLLECTION and ICollection.providedBy(item): collection = item.getQuery() if collection: result[item.title_or_id()] = [] walk(collection, result, item.title_or_id()) else: # add only published items if wft.getInfoFor(item, "review_state") != "published": IStatusMessage(self.request).\ add(_(u'Some of the items in your list are private. ' 'They were not included in the wizard - ' 'MailChimp supports only published content.'), type='error') continue result[parent].append({'uid': IUUID(item), 'title': item.title_or_id()}) return result
def topicQueryString(self): # BBB: seems ununsed topic = self.rootTopic() if IATTopic.providedBy(topic): return make_query(topic.buildQuery()) else: raise NotImplementedError('No support for %s yet' % topic.portal_type)
def walk(items, result, parent): for item in items: collection = [] if COLLECTION and IContentListingObject.providedBy(item): item = item.getObject() elif IATTopic.providedBy(item): collection = item.queryCatalog(b_size=100, full_objects=True) elif COLLECTION and ICollection.providedBy(item): collection = item.getQuery() if collection: result[item.title_or_id()] = [] walk(collection, result, item.title_or_id()) else: # add only published items if wft.getInfoFor(item, "review_state") != "published": IStatusMessage(self.request).\ add(_(u'Some of the items in your list are private. ' 'They were not included in the wizard - ' 'MailChimp supports only published content.'), type='error') continue result[parent].append({ 'uid': IUUID(item), 'title': item.title_or_id() }) return result
def getEvents(self): if IEvent.providedBy(self.context): return [self.context] context = aq_inner(self.context) query = {'object_provides':IEvent.__identifier__} if not IATTopic.providedBy(context): query['path'] = '/'.join(context.getPhysicalPath()) return [item.getObject() for item in context.queryCatalog(REQUEST=query)]
def getRoute(self): """ Returns a list of IGisFile files """ query = {'object_provides': IGisFile.__identifier__} if IATTopic.providedBy(self.context): return self.context.queryCatalog(**query) elif IATFolder.providedBy(self.context)\ or IPloneSiteRoot.providedBy(self.context): return self.context.getFolderContents(query) else: logger.info('Unsupported container type') return []
def get_collection_query(obj): """ return collection's query params """ if IATTopic.providedBy(obj): # old style collection return obj.buildQuery() if ICollection.providedBy(obj): # new style collection return parse_new_collection_query(obj)
def _render_cachekey(fun, self): context = aq_inner(self.context) if not self.updated: self.update() if self.calendar.getUseSession(): raise ram.DontCache() else: portal_state = getMultiAdapter((context, self.request), name=u'plone_portal_state') key = StringIO() print >> key, [k.encode('utf-8') for k in self.data.kw] print >> key, self.data.review_state print >> key, self.data.name print >> key, portal_state.navigation_root_url() print >> key, cache.get_language(context, self.request) print >> key, self.calendar.getFirstWeekDay() year, month = self.getYearAndMonthToDisplay() print >> key, year print >> key, month navigation_root_path = self.root() start = DateTime('%s/%s/1' % (year, month)) end = DateTime('%s/%s/1 23:59:59' % self.getNextMonth(year, month)) - 1 catalog = getToolByName(context, 'portal_catalog') self.options = {} if navigation_root_path: root_content = self.context.restrictedTraverse( navigation_root_path) if IATTopic.providedBy(root_content): self.options = root_content.buildQuery() elif ICollection.providedBy(root_content): self.options = parseFormquery( root_content, root_content.getField('query').getRaw(root_content)) print >> key, root_content.modified() self.options['start'] = {'query': end, 'range': 'max'} self.options['end'] = {'query': start, 'range': 'min'} _define_search_options(self, self.options) brains = catalog(**self.options) for brain in brains: add_cachekey(key, brain) return key.getvalue()
def getEventsForCalendar(self): navigation_root_path = self.root() self.options = {} if navigation_root_path: root_content = self.rootTopic() if root_content: if IATTopic.providedBy(root_content): self.options = root_content.buildQuery() elif ICollection.providedBy(root_content): self.options = parseFormquery(root_content, root_content.getField('query').getRaw(root_content)) _define_search_options(self, self.options) weeks = self._get_calendar_structure() return weeks
def _render_cachekey(fun, self): context = aq_inner(self.context) if not self.updated: self.update() if self.calendar.getUseSession(): raise ram.DontCache() else: portal_state = getMultiAdapter( (context, self.request), name=u'plone_portal_state') key = StringIO() print >> key, [k.encode('utf-8') for k in self.data.kw] print >> key, self.data.review_state print >> key, self.data.name print >> key, portal_state.navigation_root_url() print >> key, cache.get_language(context, self.request) print >> key, self.calendar.getFirstWeekDay() year, month = self.getYearAndMonthToDisplay() print >> key, year print >> key, month navigation_root_path = self.root() start = DateTime('%s/%s/1' % (year, month)) end = DateTime('%s/%s/1 23:59:59' % self.getNextMonth(year, month)) - 1 catalog = getToolByName(context, 'portal_catalog') self.options = {} if navigation_root_path: root_content = self.context.restrictedTraverse(navigation_root_path) if IATTopic.providedBy(root_content): self.options = root_content.buildQuery() elif ICollection.providedBy(root_content): self.options = parseFormquery(root_content, root_content.getField('query').getRaw(root_content)) print >> key, root_content.modified() self.options['start'] = {'query': end, 'range': 'max'} self.options['end'] = {'query': start, 'range': 'min'} _define_search_options(self, self.options) brains = catalog(**self.options) for brain in brains: add_cachekey(key, brain) return key.getvalue()
def getEventsForCalendar(self): navigation_root_path = self.root() self.options = {} if navigation_root_path: root_content = self.rootTopic() if root_content: if IATTopic.providedBy(root_content): self.options = root_content.buildQuery() elif ICollection.providedBy(root_content): self.options = parseFormquery( root_content, root_content.getField('query').getRaw(root_content)) _define_search_options(self, self.options) weeks = self._get_calendar_structure() return weeks
def __init__(self, context, request): self.facet_fields = filter_facets self.default_query = {'portal_type': PORTAL_TYPES, 'facet': 'true', 'facet.field': self.facet_fields, 'b_size': 10, 'b_start': 0, } if IATTopic.providedBy(context): self.default_query.update(context.buildQuery()) #self.vocDict = {'languageReview': listAvailableContentLanguages()} registry = queryUtility(IRegistry) settings = registry.forInterface(IRecensioSettings) allowed_langs = getattr(settings, 'available_content_languages', '').replace('\r', '').split('\n') self.vocDict = {'languageReview': DisplayList([(x, x) for x in allowed_langs])} self.submenus = [ dict(title='Language',id='languageReview'),] self.queryparam = 'languageReview' BrowserView.__init__(self, context, request)
def is_topic(self): ctx = self.default_context return IATTopic and IATTopic.providedBy(ctx) or False
def is_collection(obj): """ return true if given obj is a plone collection """ return IATTopic.providedBy(obj) or \ ICollection.providedBy(obj) or \ IOldCollection.providedBy(obj)
def update(self): context = aq_inner(self.context) query = {'object_provides':ICalendarSupport.__identifier__} if not IATTopic.providedBy(context): query['path'] = '/'.join(context.getPhysicalPath()) self.events = context.queryCatalog(REQUEST=query)
def rootTopic(self): topic = self.context.restrictedTraverse(self.root()) if IATTopic.providedBy(topic) or ICollection.providedBy(topic): return topic return None
def is_collection(obj): """ return true if given obj is a plone collection """ return IATTopic.providedBy(obj) or ICollection.providedBy(obj)
def is_collection(obj): return IATTopic.providedBy(obj) or ICollection.providedBy(obj)