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


Python URL.qs_set方法代碼示例

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


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

示例1: test_params_set_args

# 需要導入模塊: from iktomi.web.reverse import URL [as 別名]
# 或者: from iktomi.web.reverse.URL import qs_set [as 別名]
 def test_params_set_args(self):
     'Use multidict to set params in url'
     url = URL('/')
     self.assertEqual(url.qs_set(a=1, b=2), '/?a=1&b=2')
     url = url.qs_set([('a', '1'), ('a', '2'), ('b', '3')])
     self.assertEqual(url, '/?a=1&a=2&b=3')
     self.assertEqual(url.qs_set([('a', '1'), ('c', '2')]), '/?b=3&a=1&c=2')
     self.assertRaises(TypeError, url.qs_set, [('a', 1)], z=0)
開發者ID:oas89,項目名稱:iktomi,代碼行數:10,代碼來源:url.py

示例2: test_param_set

# 需要導入模塊: from iktomi.web.reverse import URL [as 別名]
# 或者: from iktomi.web.reverse.URL import qs_set [as 別名]
 def test_param_set(self):
     'Set new param in url'
     u = URL('/path/to/something', query=dict(id=3, page=5, title='title'))
     self.assertEqual(u, '/path/to/something?title=title&id=3&page=5')
     u = u.qs_set(page=6)
     self.assertEqual(u, '/path/to/something?title=title&id=3&page=6')
     u = u.qs_set(page=7, title='land')
     self.assertEqual(u, '/path/to/something?id=3&page=7&title=land')
開發者ID:oas89,項目名稱:iktomi,代碼行數:10,代碼來源:url.py

示例3: test_param_set

# 需要導入模塊: from iktomi.web.reverse import URL [as 別名]
# 或者: from iktomi.web.reverse.URL import qs_set [as 別名]
 def test_param_set(self):
     'Set new param in url'
     u = URL('/path/to/something', query=[('title', 'title'), ('id', 3), ('page', 5)])
     self.assertEqual(u, '/path/to/something?title=title&id=3&page=5')
     if six.PY2:
         u = u.qs_set(page=long(2))
         self.assertEqual(u, '/path/to/something?title=title&id=3&page=2')
     u = u.qs_set(page=6)
     self.assertEqual(u, '/path/to/something?title=title&id=3&page=6')
     u = u.qs_set(page=7, title='land')
     self.assertIn(u, ['/path/to/something?id=3&page=7&title=land',
                       '/path/to/something?id=3&title=land&page=7'])
開發者ID:SmartTeleMax,項目名稱:iktomi,代碼行數:14,代碼來源:url.py

示例4: test_param_get

# 需要導入模塊: from iktomi.web.reverse import URL [as 別名]
# 或者: from iktomi.web.reverse.URL import qs_set [as 別名]
 def test_param_get(self):
     'Get param from url'
     u = URL('/path/to/something', query=dict(id=3, page=5, title='title'))
     page = u.qs_get('page')
     self.assertEqual(page, 5)
     u = u.qs_set(page=7)
     page = u.qs_get('page')
     self.assertEqual(page, 7)
     not_here = u.qs_get('not_here')
     self.assertEqual(not_here, None)
開發者ID:oas89,項目名稱:iktomi,代碼行數:12,代碼來源:url.py

示例5: test_iri

# 需要導入模塊: from iktomi.web.reverse import URL [as 別名]
# 或者: from iktomi.web.reverse.URL import qs_set [as 別名]
 def test_iri(self):
     u = URL('/', host=u'example.com')
     self.assertEqual(u, u'http://example.com/')
     u = URL(u'/урл/', host=u'сайт.рф', query={'q': u'поиск'}, fragment=u"якорь")
     self.assertEqual(u, u'http://xn--80aswg.xn--p1ai'
                                 u'/%D1%83%D1%80%D0%BB/'
                                 u'?q=%D0%BF%D0%BE%D0%B8%D1%81%D0%BA'
                                 u'#%D1%8F%D0%BA%D0%BE%D1%80%D1%8C')
     # Note: you should probably not use unicode in fragment part of URL.
     #       We encode it according to RFC, but different client handle
     #       it in different ways: Chrome allows unicode and does not
     #       encode/decode it at all, while Firefox handles it according RFC
     self.assertEqual(u.qs_set(a=u'1'), u'http://xn--80aswg.xn--p1ai'
                                 u'/%D1%83%D1%80%D0%BB/'
                                 u'?q=%D0%BF%D0%BE%D0%B8%D1%81%D0%BA&a=1'
                                 u'#%D1%8F%D0%BA%D0%BE%D1%80%D1%8C')
開發者ID:SmartTeleMax,項目名稱:iktomi,代碼行數:18,代碼來源:url.py

示例6: test_quote

# 需要導入模塊: from iktomi.web.reverse import URL [as 別名]
# 或者: from iktomi.web.reverse.URL import qs_set [as 別名]
 def test_quote(self):
     u = URL(quote('/path/to/+'))
     self.assertEqual(u, '/path/to/%2B')
     u = u.qs_set(page=7)
     self.assertEqual(u, '/path/to/%2B?page=7')
開發者ID:oas89,項目名稱:iktomi,代碼行數:7,代碼來源:url.py


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