Django

Code

Changeset 5338

Show
Ignore:
Timestamp:
05/25/07 02:25:34 (1 year ago)
Author:
mtredinnick
Message:

unicode: Added a unicode-aware version of urlencode. Since we now have a
collection of URL encoding functions, moved them into django.utils.http
(out of django.utils.html).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/unicode/django/test/client.py

    r5242 r5338  
    1111from django.core.signals import got_request_exception 
    1212from django.dispatch import dispatcher 
    13 from django.http import urlencode, SimpleCookie, HttpRequest 
     13from django.http import SimpleCookie, HttpRequest 
    1414from django.test import signals 
    1515from django.utils.functional import curry 
    1616from django.utils.encoding import smart_str 
     17from django.utils.http import urlencode 
    1718 
    1819BOUNDARY = 'BoUnDaRyStRiNg' 
  • django/branches/unicode/django/utils/html.py

    r5328 r5338  
    126126clean_html = allow_lazy(clean_html, unicode) 
    127127 
    128 def urlquote(url, safe='/'): 
    129     """ 
    130     A version of Python's urllib.quote() function that can operate on unicode 
    131     strings. The url is first UTF-8 encoded before quoting. The returned string 
    132     can safely be used as part of an argument to a subsequent iri_to_uri() call 
    133     without double-quoting occurring. 
    134     """ 
    135     return force_unicode(urllib.quote(smart_str(url))) 
    136 urlquote = allow_lazy(urlquote, unicode) 
    137  
    138 def urlquote_plus(url, safe=''): 
    139     """ 
    140     A version of Python's urllib.quote_plus() function that can operate on 
    141     unicode strings. The url is first UTF-8 encoded before quoting. The 
    142     returned string can safely be used as part of an argument to a subsequent 
    143     iri_to_uri() call without double-quoting occurring. 
    144     """ 
    145     return force_unicode(urllib.quote_plus(smart_str(url), safe)) 
    146 urlquote_plus = allow_lazy(urlquote_plus, unicode) 
  • django/branches/unicode/docs/unicode.txt

    r5334 r5338  
    150150      conversion from IRI to URI as required by `the specification`_. 
    151151 
    152     * The functions ``django.utils.html.urlquote()`` and 
    153       ``django.utils.html.urlquote_plus()`` are versions of Python's standard 
     152    * The functions ``django.utils.http.urlquote()`` and 
     153      ``django.utils.http.urlquote_plus()`` are versions of Python's standard 
    154154      ``urllib.quote()`` and ``urllib.quote_plus()`` that work with non-ASCII 
    155155      characters (the data is converted to UTF-8 prior to encoding). 
     
    236236 
    237237    from django.utils.encoding import iri_to_uri 
    238     from django.utils.html import urlquote 
     238    from django.utils.http import urlquote 
    239239 
    240240    def get_absolute_url(self): 
  • django/branches/unicode/tests/modeltests/test_client/models.py

    r5185 r5338  
     1# coding: utf-8 
    12""" 
    2338. Testing using the Test Client 
     
    2829    def test_get_view(self): 
    2930        "GET a view" 
    30         response = self.client.get('/test_client/get_view/') 
     31        # The data is ignored, but let's check it doesn't crash the system 
     32        # anyway. 
     33        data = {'var': u'\xf2'} 
     34        response = self.client.get('/test_client/get_view/', data) 
    3135         
    3236        # Check some response details 
    3337        self.assertContains(response, 'This is a test') 
    34         self.assertEqual(response.context['var'], 42
     38        self.assertEqual(response.context['var'], u'\xf2'
    3539        self.assertEqual(response.template.name, 'GET Template') 
    3640 
  • django/branches/unicode/tests/modeltests/test_client/views.py

    r5185 r5338  
    1111    "A simple view that expects a GET request, and returns a rendered template" 
    1212    t = Template('This is a test. {{ var }} is the value.', name='GET Template') 
    13     c = Context({'var': 42}) 
     13    c = Context({'var': request.GET.get('var', 42)}) 
    1414     
    1515    return HttpResponse(t.render(c)) 
  • django/branches/unicode/tests/regressiontests/text/tests.py

    r5328 r5338  
    1818 
    1919### urlquote ############################################################# 
    20 >>> from django.utils.html import urlquote, urlquote_plus 
     20>>> from django.utils.http import urlquote, urlquote_plus 
    2121>>> urlquote(u'Paris & Orl\xe9ans') 
    2222u'Paris%20%26%20Orl%C3%A9ans'