當前位置: 首頁>>代碼示例>>Python>>正文


Python FilterChain.keys方法代碼示例

本文整理匯總了Python中ebpub.db.schemafilters.FilterChain.keys方法的典型用法代碼示例。如果您正苦於以下問題:Python FilterChain.keys方法的具體用法?Python FilterChain.keys怎麽用?Python FilterChain.keys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ebpub.db.schemafilters.FilterChain的用法示例。


在下文中一共展示了FilterChain.keys方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_ordering

# 需要導入模塊: from ebpub.db.schemafilters import FilterChain [as 別名]
# 或者: from ebpub.db.schemafilters.FilterChain import keys [as 別名]
 def test_ordering(self):
     chain = FilterChain()
     args = range(10)
     random.shuffle(args)
     for i in args:
         chain[i] = i
     self.assertEqual(chain.items(), [(i, i) for i in args])
     self.assertEqual(chain.keys(), args)
開發者ID:horshacktest,項目名稱:openblock,代碼行數:10,代碼來源:test_schemafilters.py

示例2: _decode_map_permalink

# 需要導入模塊: from ebpub.db.schemafilters import FilterChain [as 別名]
# 或者: from ebpub.db.schemafilters.FilterChain import keys [as 別名]

#.........這裏部分代碼省略.........
        if no_layers_specified and show_default_layers and not show_custom_layer:
            # default on if no 't' param given
            visible = True
        elif schemas and schema.id in schemas:
            visible = True
        else:
            visible = False
        layers.append({
            'id': 't%d' % schema.id,
            'title':  schema.plural_name,
            'url':    reverse('map_items_json'),
            'params': {'type': schema.slug, 'limit': 1000,
                       'startdate': api_startdate,
                       'enddate': api_enddate},
            'bbox': False,
            'visible': visible
        })

    # Explicit filtering by ID.
    ids = params.get('i') or u''
    ids = [i.strip() for i in re.split(r'[^\d]+', ids)
           if i.strip()]
    if ids:
        show_custom_layer = True
        if filters is None:
            filters = FilterChain(request)
        filters.replace('id', *ids)


    # 'Custom' layer. This is a catch-all for all filtering
    # that isn't just enabling a default layer with the default
    # date range.
    # Not visible unless there is something like that to show.
    if filters and sorted(filters.keys()) not in ([],
                                                  ['date'],
                                                  ['date', 'schema'],
                                                  ['schema']):
        show_custom_layer = True

    if filters is not None:
        # Don't inspect filters['schema']; that's already covered by schemas above.
        base_url = reverse('map_items_json')
        layer_url = filters.make_url(base_url=base_url)
        # Quick ugly hacks to make the itemquery api happy.
        # Hooray proliferation of spellings.
        layer_url = layer_url.replace('locations=', 'locationid=')
        layer_url = layer_url.replace('start_date=', 'startdate=')
        layer_url = layer_url.replace('end_date=', 'enddate=')

        if 'schema' in filters:
            # Normally, filters.make_url() captures the schema in the
            # path part of the URL. But map_items_json doesn't,
            # so we add a query parameter.
            params = {'type': [s.slug for s in filters['schema'].schemas]}
        else:
            params = {}
        custom_layer = {
            'url': layer_url,
            'params': params,
            'title': u"Custom Filter",
            'visible': show_custom_layer,
            'id': 'c1',
            }
        layers.append(custom_layer)

    is_widget = params.get('x', None) is not None
開發者ID:DotNetWebs,項目名稱:openblock,代碼行數:70,代碼來源:views.py


注:本文中的ebpub.db.schemafilters.FilterChain.keys方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。