Esempio n. 1
0
        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)
Esempio n. 3
0
        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
Esempio n. 4
0
 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 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)
Esempio n. 6
0
 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 []
Esempio n. 7
0
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 wireAddPermissions():
    """Creates a list of add permissions for all types in this project

    Must be called **after** all types are registered!
    """
    global permissions
    atct_types = listTypes(PROJECTNAME)
    for atct in atct_types:
        if IATTopic.implementedBy(atct['klass']):
            permission = AddTopics
        elif IATTopicCriterion.implementedBy(atct['klass']):
            permission = "%s Topic: Add %s" % (PROJECTNAME, atct['portal_type'])
            setDefaultRoles(permission, CRITERION_ROLES)
        else:
            permission = "%s: Add %s" % (PROJECTNAME, atct['portal_type'])
            setDefaultRoles(permission, TYPE_ROLES)

        permissions[atct['portal_type']] = permission
    return permissions
Esempio n. 13
0
    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)
Esempio n. 14
0
 def is_topic(self):
     ctx = self.default_context
     return IATTopic and IATTopic.providedBy(ctx) or False
Esempio n. 15
0
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)
Esempio n. 16
0
 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
Esempio n. 18
0
def is_collection(obj):
    """ return true if given obj is a plone collection
    """
    return IATTopic.providedBy(obj) or ICollection.providedBy(obj)
Esempio n. 19
0
def is_collection(obj):
    return IATTopic.providedBy(obj) or ICollection.providedBy(obj)
Esempio n. 20
0
 def is_topic(self):
     ctx = self.default_context
     return IATTopic and IATTopic.providedBy(ctx) or False
 def rootTopic(self):
     topic = self.context.restrictedTraverse(self.root())
     if IATTopic.providedBy(topic) or ICollection.providedBy(topic):
         return topic
     return None