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


Python multidict.MultiDict方法代码示例

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


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

示例1: test_post

# 需要导入模块: from webob import multidict [as 别名]
# 或者: from webob.multidict import MultiDict [as 别名]
def test_post(self):
    request = webapp2.Request.blank(
        '/blobstore',
        method='POST',
        POST=multidict.MultiDict([('blob_key', 'a'),
                                  ('blob_key', 'b')]))
    response = webapp2.Response()
    handler = blobstore_viewer.BlobstoreRequestHandler(request, response)

    self.mox.StubOutWithMock(blobstore, 'delete')
    blobstore.delete(['a', 'b'])

    self.mox.ReplayAll()
    handler.post()
    self.mox.VerifyAll()
    self.assertEqual(302, response.status_int)
    self.assertEqual('http://localhost/blobstore',
                     response.headers.get('Location')) 
开发者ID:elsigh,项目名称:browserscope,代码行数:20,代码来源:blobstore_viewer_test.py

示例2: transform

# 需要导入模块: from webob import multidict [as 别名]
# 或者: from webob.multidict import MultiDict [as 别名]
def transform(self, fn, decode=False):
        """Accepts a function, getting a key, val and returning
        a new pair of key, val and applies the function to all
        header, value pairs in the message.
        """

        changed = [False]

        def tracking_fn(key, val):
            new_key, new_val = fn(key, val)
            if new_val != val or new_key != key:
                changed[0] = True
            return new_key, new_val

        v = MultiDict(tracking_fn(key, val) for key, val in self.iteritems(raw=not decode))
        if changed[0]:
            self._v = v
            self.changed = True 
开发者ID:duo-labs,项目名称:isthislegit,代码行数:20,代码来源:headers.py

示例3: test_multiple__convert_to_dict_list__order_also_same

# 需要导入模块: from webob import multidict [as 别名]
# 或者: from webob.multidict import MultiDict [as 别名]
def test_multiple__convert_to_dict_list__order_also_same():
    from webob.multidict import MultiDict

    mdict = MultiDict(
        [
            ("name", "foo"),
            ("country", "jp"),
            ("name", "bar"),
            ("country", "us"),
            ("name", "boo"),
            ("country", "ch"),
        ]
    )
    result = _callFUT(mdict)
    assert result == [
        {"name": "foo", "country": "jp"},
        {"name": "bar", "country": "us"},
        {"name": "boo", "country": "ch"},
    ] 
开发者ID:podhmo,项目名称:alchemyjsonschema,代码行数:21,代码来源:test_parser.py

示例4: test_multiple2__convert_to_dict_list__order_also_same

# 需要导入模块: from webob import multidict [as 别名]
# 或者: from webob.multidict import MultiDict [as 别名]
def test_multiple2__convert_to_dict_list__order_also_same():
    from webob.multidict import MultiDict

    mdict = MultiDict(
        [
            ("name", "foo"),
            ("name", "bar"),
            ("name", "boo"),
            ("country", "jp"),
            ("country", "us"),
            ("country", "ch"),
        ]
    )
    result = _callFUT(mdict)
    assert result == [
        {"name": "foo", "country": "jp"},
        {"name": "bar", "country": "us"},
        {"name": "boo", "country": "ch"},
    ] 
开发者ID:podhmo,项目名称:alchemyjsonschema,代码行数:21,代码来源:test_parser.py

示例5: test_post

# 需要导入模块: from webob import multidict [as 别名]
# 或者: from webob.multidict import MultiDict [as 别名]
def test_post(self):
    request = webapp2.Request.blank(
        '/blobstore',
        method='POST',
        POST=multidict.MultiDict([('blob_key', 'a'),
                                  ('blob_key', 'b')]))
    response = webapp2.Response()
    handler = blobstore_viewer.BlobstoreRequestHandler(request, response)
    admin_request_handler.AdminRequestHandler(handler).post()
    self.mox.StubOutWithMock(blobstore, 'delete')
    blobstore.delete(['a', 'b'])

    self.mox.ReplayAll()
    handler.post()
    self.mox.VerifyAll()
    self.assertEqual(302, response.status_int)
    self.assertEqual('http://localhost/blobstore',
                     response.headers.get('Location')) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:20,代码来源:blobstore_viewer_test.py

示例6: test_03_search_url_multiple_words

# 需要导入模块: from webob import multidict [as 别名]
# 或者: from webob.multidict import MultiDict [as 别名]
def test_03_search_url_multiple_words(self):
        fields = UnicodeMultiDict(MultiDict(url='e'))
        fields.add('url', 'f')
        urls = self.res_search(fields=fields)
        assert set([self.ef]) == urls, urls 
开发者ID:italia,项目名称:daf-recipes,代码行数:7,代码来源:test_resource_search.py

示例7: __init__

# 需要导入模块: from webob import multidict [as 别名]
# 或者: from webob.multidict import MultiDict [as 别名]
def __init__(self, items=()):
        self._v = MultiDict([(normalize(key), remove_newlines(val))
                             for (key, val) in items])
        self.changed = False
        self.num_prepends = 0 
开发者ID:duo-labs,项目名称:isthislegit,代码行数:7,代码来源:headers.py

示例8: transform

# 需要导入模块: from webob import multidict [as 别名]
# 或者: from webob.multidict import MultiDict [as 别名]
def transform(self, func):
        changed = [False]

        def wrapped_func(key, value):
            new_key, new_value = func(key, value)
            if new_value != value or new_key != key:
                changed[0] = True
            return new_key, new_value

        transformed_headers = [wrapped_func(k, v) for k, v in self._m.items()]
        if changed[0]:
            self._m._headers = transformed_headers
            self._v = MultiDict([(normalize(k), remove_newlines(v))
                                 for k, v in transformed_headers])
            self.changed = True 
开发者ID:duo-labs,项目名称:isthislegit,代码行数:17,代码来源:part.py

示例9: __make_request_params

# 需要导入模块: from webob import multidict [as 别名]
# 或者: from webob.multidict import MultiDict [as 别名]
def __make_request_params(kwargs):
        params = MultiDict()
        for key, val in kwargs.iteritems():
            assert isinstance(key, basestring)
            if isinstance(val, basestring):
                params[key] = val
            else:
                assert isinstance(val, (list, tuple))
                for v in val:
                    assert isinstance(v, basestring)
                    params.add(key, v)
        return params 
开发者ID:CERT-Polska,项目名称:n6,代码行数:14,代码来源:unit_test_helpers.py

示例10: _sanitizer

# 需要导入模块: from webob import multidict [as 别名]
# 或者: from webob.multidict import MultiDict [as 别名]
def _sanitizer(self, obj):
        """Sanitizer method that will be passed to jsonutils.dumps."""
        if hasattr(obj, "to_dict"):
            return obj.to_dict()
        if isinstance(obj, multidict.MultiDict):
            return obj.mixed()
        return jsonutils.to_primitive(obj) 
开发者ID:openstack,项目名称:searchlight,代码行数:9,代码来源:wsgi.py

示例11: __init__

# 需要导入模块: from webob import multidict [as 别名]
# 或者: from webob.multidict import MultiDict [as 别名]
def __init__(self, **kw):
        super(EnhancedDummyRequest, self).__init__(**kw)
        self.GET = MultiDict(self.GET)
        # Make sure content_type attr exists is not passed in via **kw
        self.content_type = getattr(self, 'content_type', None) 
开发者ID:striglia,项目名称:pyramid_swagger,代码行数:7,代码来源:response_test.py

示例12: test_view

# 需要导入模块: from webob import multidict [as 别名]
# 或者: from webob.multidict import MultiDict [as 别名]
def test_view(self, by_resource_id):
        from pyramid.httpexceptions import HTTPFound
        AccomodationsView._get_title = lambda x, y=None: 'test'

        view = AccomodationsView(
            DummyResource(), DummyRequest(params=MultiDict({'rid': 1}))
        )
        self.assertIsInstance(view.view(), HTTPFound)

        AccomodationsView.edit = lambda x=None: {}
        view = AccomodationsView(DummyResource(), DummyRequest())
        self.assertSetEqual({'title', 'readonly'}, set(view.view().keys())) 
开发者ID:mazvv,项目名称:travelcrm,代码行数:14,代码来源:test_accomodations.py

示例13: test_form_invalid

# 需要导入模块: from webob import multidict [as 别名]
# 或者: from webob.multidict import MultiDict [as 别名]
def test_form_invalid(self):
        request = DummyRequest(
            params=MultiDict({'address': 'a'})
        )
        form = AddressForm(request)
        self.assertFalse(form.validate())
        
        self.assertIn('location_id', form._errors)
        self.assertIn('zip_code', form._errors)
        self.assertIn('address', form._errors) 
开发者ID:mazvv,项目名称:travelcrm,代码行数:12,代码来源:test_adress.py

示例14: test_form_valid

# 需要导入模块: from webob import multidict [as 别名]
# 或者: from webob.multidict import MultiDict [as 别名]
def test_form_valid(self):
        request = DummyRequest()
        csrf_token = request.session.get_csrf_token()
        request.params = (
            MultiDict({
                'csrf_token': csrf_token,
                'location_id': 10,
                'zip_code': '02121',
                'address': 'test'
            })
        )
        form = AddressForm(request)
        form.validate()
        self.assertTrue(form.validate()) 
开发者ID:mazvv,项目名称:travelcrm,代码行数:16,代码来源:test_adress.py

示例15: test_form_invalid

# 需要导入模块: from webob import multidict [as 别名]
# 或者: from webob.multidict import MultiDict [as 别名]
def test_form_invalid(self):
        request = DummyRequest(params=MultiDict())
        form = AdvsourceForm(request)
        self.assertFalse(form.validate())
        
        self.assertIn('name', form._errors) 
开发者ID:mazvv,项目名称:travelcrm,代码行数:8,代码来源:test_advsource.py


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