當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。