[Checkins] SVN: grokcore.view/branches/1.13/src/grokcore/view/ftests/url/url_function.py some of the data={} argument handling on the url() method has moved to the url() utility function; move the tests too
Jan-Wijbrand Kolman
janwijbrand at gmail.com
Fri Nov 27 05:20:16 EST 2009
Log message for revision 106053:
some of the data={} argument handling on the url() method has moved to the url() utility function; move the tests too
Changed:
U grokcore.view/branches/1.13/src/grokcore/view/ftests/url/url_function.py
-=-
Modified: grokcore.view/branches/1.13/src/grokcore/view/ftests/url/url_function.py
===================================================================
--- grokcore.view/branches/1.13/src/grokcore/view/ftests/url/url_function.py 2009-11-27 10:08:19 UTC (rev 106052)
+++ grokcore.view/branches/1.13/src/grokcore/view/ftests/url/url_function.py 2009-11-27 10:20:16 UTC (rev 106053)
@@ -61,6 +61,41 @@
>>> expected = unicode('http://127.0.0.1/herd/árgh', 'UTF-8')
>>> urllib.unquote(u).decode('utf-8') == expected
True
+
+The url() function supports a data argument which is converted to a
+CGI type query string. If any of the values are of type unicode it's
+converted to a string assuming the encoding is UTF-8:
+
+ >>> url(request, herd, '@@sample_view', data=dict(age=28))
+ 'http://127.0.0.1/herd/@@sample_view?age=28'
+
+ >>> url(request, herd, data=dict(age=28))
+ 'http://127.0.0.1/herd?age=28'
+
+There is no problem putting one of the 'reserved' arguments inside the data
+argument or explicitely supplying 'None':
+
+ >>> url(request, herd, None, data=dict(name="Peter"))
+ 'http://127.0.0.1/herd?name=Peter'
+
+Since order in dictionairies is arbitrary we'll test the presence of multiple
+keywords by using find()
+
+ >>> withquery = url(request, herd, 'sample_view', data=dict(a=1, b=2, c=3))
+ >>> withquery.find('a=1') > -1
+ True
+
+ >>> withquery.find('b=2') > -1
+ True
+
+ >>> withquery.find('c=3') > -1
+ True
+
+ >>> url(request, herd, 'bar', data='baz')
+ Traceback (most recent call last):
+ ...
+ TypeError: url() data argument must be a dict.
+
"""
import grokcore.view as grok
from grokcore.view import url
More information about the checkins
mailing list