当前位置: 首页>>代码示例>>Python>>正文


Python interfaces.ICollection类代码示例

本文整理汇总了Python中plone.app.collection.interfaces.ICollection的典型用法代码示例。如果您正苦于以下问题:Python ICollection类的具体用法?Python ICollection怎么用?Python ICollection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ICollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: queryCatalog

    def queryCatalog(self, limit):
        """
        """
        querybuilder = QueryBuilder(self, self.request)
        if not hasattr(self.data, 'sort_on'):
            self.data.sort_on = 'effective'
        if not hasattr(self.data, 'sort_order'):
            self.data.sort_order = False
        if not hasattr(self.data, 'sort_folderorder'):
            self.data.sort_folderorder = False

        sort_order = 'descending' if self.data.sort_order else 'ascending'
        sort_on = self.data.sort_on

        if self.data.sort_folderorder:
            sort_on = 'getObjPositionInParent'

        query = list(self.data.query)

        if ICollection.providedBy(self.context):
            query += self.context.query and self.context.query or []
            parent = aq_parent(aq_inner(self.context))
            if ICollection.providedBy(parent):
                query += parent.query and parent.query or []
        return querybuilder(query=query,
                            sort_on=sort_on,
                            sort_order=sort_order,
                            limit=limit)
开发者ID:UPCnet,项目名称:genweb.smartportlet,代码行数:28,代码来源:__init__.py

示例2: walk

        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
开发者ID:RedTurtle,项目名称:redturtle.monkey,代码行数:26,代码来源:campaign.py

示例3: contentsMethod

 def contentsMethod(self):
     context = aq_inner(self.context)
     if IATTopic.providedBy(context) or ICollection.providedBy(context):
         contentsMethod = context.queryCatalog
     else:
         contentsMethod = context.getFolderContents
     return contentsMethod
开发者ID:redomino,项目名称:redomino.tabsandslides,代码行数:7,代码来源:common.py

示例4: get_items

    def get_items(self):
        context = aq_inner(self.context)
        if IATFolder.providedBy(context) or \
                IATBTreeFolder.providedBy(context):
            res = self.context.getFolderContents(
                contentFilter={
                    'sort_on': 'getObjPositionInParent',
                    'portal_type': self.settings.allowed_types,
                    'limit': self.settings.limit
                }
            )
        elif IATTopic.providedBy(context):
            if self.settings.limit and self.settings.limit > 0:
                res = context.queryCatalog(batch=True,
                                           b_size=self.settings.limit,
                                           portal_type=
                                           self.settings.allowed_types,
                                           )
            else:
                res = context.queryCatalog(
                    portal_type=self.settings.allowed_types,
                    limit=self.settings.limit
                )
        elif ICollection.providedBy(context):
            query = queryparser.parseFormquery(
                context, context.getRawQuery())
            query['portal_type'] = self.settings.allowed_types
            query['limit'] = self.settings.limit
            if self.settings.limit and self.settings.limit > 0:
                res = context.queryCatalog(batch=True,
                                           b_size=self.settings.limit)
            else:
                res = context.queryCatalog(query)

        return res
开发者ID:EricGrivilers,项目名称:collective.easyslider,代码行数:35,代码来源:views.py

示例5: editCarouselLink

 def editCarouselLink(self):
     provider = self.collection()
     if provider is not None:
         if ICollection.providedBy(provider):
             return provider.absolute_url() + '/edit'
         return provider.absolute_url() + '/criterion_edit_form'
     return None
开发者ID:RedTurtle,项目名称:collective.carousel,代码行数:7,代码来源:carousel.py

示例6: getCriteriaKeys

 def getCriteriaKeys(self):
     li = []
     if IATTopic.providedBy(self.context) or ICollection.providedBy(self.context) or IDXCollection.providedBy(self.context):
         criteria = IListBaseQueryCriteria(self.context)()
         for criterion in [a['i'] for a in criteria]:
             li.append(self.name+'.'+criterion)
     return li
开发者ID:collective,项目名称:Solgema.fullcalendar,代码行数:7,代码来源:widgets.py

示例7: __call__

    def __call__(self, context, **query):
        ctool = getToolByName(context, 'portal_faceted', None)
        if ctool:
            search = ctool.search
        else:
            logger.debug('portal_faceted not present, using portal_catalog')
            ctool = getToolByName(context, 'portal_catalog')
            search = ctool.searchResults

        # Also get query from Topic
        buildQuery = getattr(context, 'buildQuery', None)
        newquery = buildQuery and buildQuery() or {}
        formquery = None

        # Get query from Collection
        if HAS_PAT:
            if PACI.ICollection.providedBy(context):
                infos = ICollection_behavior(context)
                sort_order = ('descending'
                              if infos.sort_reversed
                              else 'ascending')
                sort_on = infos.sort_on
                formquery = infos.query

        if ICollection.providedBy(context):
            getRawQuery = getattr(context, 'getRawQuery', lambda: [])
            formquery = getRawQuery()

            getSortOn = getattr(context, 'getSort_on', lambda: None)
            sort_on = getSortOn()

            if sort_on:
                getSortReversed = getattr(
                    context, 'getSort_reversed', lambda: None)
                sort_order = getSortReversed()
                if sort_order:
                    sort_order = 'descending'
                else:
                    sort_order = 'ascending'
            else:
                sort_order = None

        if formquery is not None:
            newquery = parseFormquery(context, formquery, sort_on, sort_order)

        if not isinstance(newquery, dict):
            newquery = {}

        # Avoid mixing sorting params from faceted and collection
        if 'sort_on' not in query:
            query.pop('sort_order', None)

        if 'sort_on' in query and 'sort_order' not in query:
            newquery.pop('sort_order', None)

        newquery.update(query)

        notify(QueryWillBeExecutedEvent(context, newquery))
        return search(**newquery)
开发者ID:Martronic-SA,项目名称:eea.facetednavigation,代码行数:59,代码来源:catalog.py

示例8: available

 def available(self):
     # only show on collection/topic
     if not self.context.restrictedTraverse('@@iscalendarlayout')():
         return False
     if ICollection.providedBy(self.context):
         return True
     if IATTopic.providedBy(self.context):
         return True
     return False
开发者ID:ploneUN,项目名称:ploneun.calendar,代码行数:9,代码来源:listingbuttons.py

示例9: get_collection_query

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)
开发者ID:abstract-open-solutions,项目名称:collective.basesearch,代码行数:11,代码来源:utils.py

示例10: edit_collection

 def edit_collection(self):
     provider = self.collection()
     smanager = SecurityManagement.getSecurityManager()
     allowed = smanager.checkPermission(ChangeTopics, provider)
     if allowed:
         provider = self.collection()
         if provider is not None:
             if ICollection.providedBy(provider):
                 return provider.absolute_url() + '/edit'
             return provider.absolute_url() + '/criterion_edit_form'
     return None
开发者ID:thet,项目名称:collective.banner,代码行数:11,代码来源:portlet.py

示例11: results

    def results(self, batch=True, b_start=0, b_size=None, inherit=False, extra=[]):
        querybuilder = QueryBuilder(self, self.REQUEST)
        sort_order = 'reverse' if self.sort_reversed else 'ascending'
        if not b_size:
            b_size = self.item_count
        query = isinstance(self.query, list) and deepcopy(self.query) or []
        if inherit:
            parent = aq_parent(self)
            if ICollection.providedBy(parent):
                query += parent.query and deepcopy(parent.query) or []
                inparent = aq_parent(self)
                if ICollection.providedBy(inparent):
                    query += inparent.query and deepcopy(inparent.query) or []
        query = query + extra

        res = querybuilder(
            query=query,
            batch=batch, b_start=b_start, b_size=b_size,
            sort_on=self.sort_on, sort_order=sort_order,
            limit=self.limit)
        return res
开发者ID:UPCnet,项目名称:vilaix.core,代码行数:21,代码来源:content.py

示例12: getCollection

    def getCollection(self, item):
        col = item.getCollection()
        if item.limit > 0:
            if HAS_COLLECTIONS and ICollection.providedBy(col) or \
                    HAS_PAC and IDXCollection.providedBy(col):
                results = col.queryCatalog(b_size=item.limit)
            else:
                results = col.queryCatalog(sort_limit=item.limit)[:item.limit]
        else:
            results = col.queryCatalog()

        return results
开发者ID:collective,项目名称:Products.Doormat,代码行数:12,代码来源:views.py

示例13: results

    def results(self, provider):
        results = []
        if provider is not None:
            # by default we assume that only Collections are addable
            # as a carousel provider

            # It doesn't make sense to show *all* objects from a collection
            # - some of them might return hundreeds of objects
            if ICollection.providedBy(provider):
                res = provider.results(b_size=7)
                return res
            return provider.queryCatalog()[:7]
        return results
开发者ID:Madec,项目名称:collective.carousel,代码行数:13,代码来源:viewlets.py

示例14: getEventsForCalendar

    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
开发者ID:collective,项目名称:collective.portlet.calendar,代码行数:15,代码来源:calendar.py

示例15: results

    def results(self, provider):
        results = []
        if provider is not None:
            # by default we assume that only Collections are addable
            # as a carousel provider

            # It doesn't make sense to show *all* objects from a collection
            # - some of them might return hundreeds of objects
            registry = getUtility(IRegistry)
            carousel_viewlet_max_size = registry.forInterface(
                ICarouselSettings, False).carousel_viewlet_max_size or 7
            if ICollection.providedBy(provider):
                res = provider.results(b_size=carousel_viewlet_max_size)
                return res
            return provider.queryCatalog()[:carousel_viewlet_max_size]
        return results
开发者ID:bogdangi,项目名称:collective.carousel,代码行数:16,代码来源:viewlets.py


注:本文中的plone.app.collection.interfaces.ICollection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。