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


Python ICriteria.get方法代码示例

本文整理汇总了Python中eea.facetednavigation.interfaces.ICriteria.get方法的典型用法代码示例。如果您正苦于以下问题:Python ICriteria.get方法的具体用法?Python ICriteria.get怎么用?Python ICriteria.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eea.facetednavigation.interfaces.ICriteria的用法示例。


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

示例1: query

# 需要导入模块: from eea.facetednavigation.interfaces import ICriteria [as 别名]
# 或者: from eea.facetednavigation.interfaces.ICriteria import get [as 别名]
    def query(self, cid, **kwargs):
        """ Count catalog items
        """
        # Cleanup query
        kwargs.pop('sort_on', None)
        kwargs.pop('sort_order', None)

        kwargs.pop(cid, None)
        self.request.form.pop(cid, None)
        # jQuery >= 1.4 adds type to params keys
        # $.param({ a: [2,3,4] }) // "a[]=2&a[]=3&a[]=4"
        # Let's fix this
        kwargs.pop(cid + '[]', None)
        self.request.form.pop(cid + '[]', None)

        criteria = ICriteria(self.context)
        criterion = criteria.get(cid)

        start = time.time()
        # Query catalog
        handler = getMultiAdapter((self.context, self.request),
                                  name=u'faceted_query')

        if criterion.get('index', '') == 'Language':
            kwargs['_language_count_'] = True
        brains = handler.query(batch=False, sort=False, **kwargs)

        # Get index
        widget = criteria.widget(cid=cid)(self.context, self.request, criterion)
        res = widget.count(brains)
        logger.debug('Benchmark %s: %s', cid, time.time() - start)
        return res
开发者ID:ichim-david,项目名称:eea.facetednavigation,代码行数:34,代码来源:counter.py

示例2: edit

# 需要导入模块: from eea.facetednavigation.interfaces import ICriteria [as 别名]
# 或者: from eea.facetednavigation.interfaces.ICriteria import get [as 别名]
    def edit(self, cid, **kwargs):
        """ See IFacetedCriterionHandler
        """
        criteria = ICriteria(self.context)
        widget = criteria.widget(cid=cid)
        criterion = criteria.get(cid)
        if kwargs.pop('__new__', False):
            criterion = criterion.__class__(cid='c0')
        widget = widget(self.context, self.request, criterion)

        wid = kwargs.pop('widget', None)
        properties = self.extractData(widget, **kwargs)
        if wid:
            properties['widget'] = wid

        update = {}
        for prop, value in properties.items():
            form_key =  'faceted.%s.%s' % (cid, prop)
            if form_key not in kwargs and value is None:
                continue
            update[prop] = value

        if update:
            criteria.edit(cid, **update)
            if widget.hidden:
                notify(FacetedGlobalSettingsChangedEvent(self.context))
            elif set(['hidden', 'operator']).intersection(update.keys()):
                notify(FacetedGlobalSettingsChangedEvent(self.context))

        return self._redirect('Changes saved')
开发者ID:Martronic-SA,项目名称:eea.facetednavigation,代码行数:32,代码来源:configure.py

示例3: __call__

# 需要导入模块: from eea.facetednavigation.interfaces import ICriteria [as 别名]
# 或者: from eea.facetednavigation.interfaces.ICriteria import get [as 别名]
    def __call__(self, **kwargs):
        if self.request:
            kwargs.update(self.request.form)

        # Calling self.index() will set cache headers for varnish
        self.index()

        cid = kwargs.pop('cid', None)
        if not cid:
            return {}

        res = self.query(cid, **kwargs)

        criteria = ICriteria(self.context)
        criterion = criteria.get(cid)
        widget = criteria.widget(cid=cid)(self.context, self.request, criterion)
        return widget(vocabulary=res)
开发者ID:Conectivo,项目名称:eea.facetednavigation,代码行数:19,代码来源:counter.py

示例4: query

# 需要导入模块: from eea.facetednavigation.interfaces import ICriteria [as 别名]
# 或者: from eea.facetednavigation.interfaces.ICriteria import get [as 别名]
    def query(self, cid, **kwargs):
        """ Count catalog items
        """
        # Cleanup query
        kwargs.pop('sort_on', None)
        kwargs.pop('sort_order', None)
        kwargs.pop(cid, None)
        self.request.form.pop(cid, None)

        criteria = ICriteria(self.context)
        criterion = criteria.get(cid)

        # Query catalog
        handler = getMultiAdapter((self.context, self.request),
                                  name=u'faceted_query')

        if criterion.get('index', '') == 'Language':
            kwargs['_language_count_'] = True
        brains = handler.query(batch=False, sort=False, **kwargs)

        # Get index
        widget = criteria.widget(cid=cid)(self.context, self.request, criterion)
        vocabulary = dict((key, value) for key, value, count
                    in widget.vocabulary(oll=True) if key not in ("", "all"))

        # Count
        count = getattr(widget, 'count', lambda brains, sequence: {})
        res = count(brains, sequence=vocabulary.keys())
        res.pop("", 0)
        oll = res.pop('all', 0)

        res = res.items()
        res.sort(key=operator.itemgetter(1), reverse=True)

        maxitems = widget.maxitems
        if maxitems:
            res = res[:maxitems]
        res.sort(key=operator.itemgetter(0), cmp=compare)

        # Return a of list of three items tuples (key, label, count)
        res = [(key, vocabulary.get(key, key), value) for key, value in res]

        res.insert(0, ('all', 'All', oll))
        for item in res:
            yield item
开发者ID:Martronic-SA,项目名称:eea.facetednavigation,代码行数:47,代码来源:counter.py

示例5: query

# 需要导入模块: from eea.facetednavigation.interfaces import ICriteria [as 别名]
# 或者: from eea.facetednavigation.interfaces.ICriteria import get [as 别名]
    def query(self, cid, **kwargs):
        """ Count catalog items
        """
        # Cleanup query
        kwargs.pop("sort_on", None)
        kwargs.pop("sort_order", None)
        kwargs.pop("sort[]", None)
        kwargs.pop("sort", None)
        kwargs.pop("reversed[]", None)
        oid = "%s-operator" % cid
        operator = kwargs.pop(oid, kwargs.pop(oid + "[]", None))

        if not operator or operator != "and":
            kwargs.pop(cid, None)
            self.request.form.pop(cid, None)
            # jQuery >= 1.4 adds type to params keys
            # $.param({ a: [2,3,4] }) // "a[]=2&a[]=3&a[]=4"
            # Let's fix this
            kwargs.pop(cid + "[]", None)
            self.request.form.pop(cid + "[]", None)

        criteria = ICriteria(self.context)
        criterion = criteria.get(cid)

        start = time.time()
        # Query catalog
        handler = getMultiAdapter((self.context, self.request), name=u"faceted_query")

        if criterion.get("index", "") == "Language":
            kwargs["_language_count_"] = True
        brains = handler.query(batch=False, sort=False, **kwargs)

        # Get index
        widget = criteria.widget(cid=cid)(self.context, self.request, criterion)
        count = getattr(widget, "count", lambda brains: {})
        res = count(brains)
        logger.debug("Benchmark %s: %s", cid, time.time() - start)
        return res
开发者ID:nagyistoce,项目名称:eea.facetednavigation,代码行数:40,代码来源:counter.py


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