#6228: Common middleware does not respect urlconf override in request
-------------------------------------+--------------------------------------
          Reporter:  trey            |         Owner:  nobody            
            Status:  new             |     Milestone:  1.2               
         Component:  Core framework  |       Version:  1.2-beta          
        Resolution:                  |      Keywords:  middleware, common
             Stage:  Accepted        |     Has_patch:  1                 
        Needs_docs:  0               |   Needs_tests:  0                 
Needs_better_patch:  0               |  
-------------------------------------+--------------------------------------
Changes (by mikexstudios):

  * needs_better_patch:  1 => 0

Comment:

 Doh! I looked at the tests again. The reason why all the tests pass
 without the patch is that the new tests test for the exact ''same'' urls
 as the tests without the overridden urlconf (that is, the tests using
 ROOT_URLCONF). Thus, when the patch wasn't applied, the new tests still
 pass because they fallback on ROOT_URLCONF, which has the exact same
 urlpattern as extra_urls.py!

 Therefore, I changed the urls in extra_urls.py by prepending them with
 "customurlconf/". For example:
 {{{
 (r'^middleware/noslash$', 'view'),
 }}}
 becomes:
 {{{
 (r'^middleware/customurlconf/noslash$', 'view'),
 }}}

 Then, I made similar changes to the new tests. For example:
 {{{
 request = self._get_request('slash')
 }}}
 becomes:
 {{{
 request = self._get_request('customurlconf/slash')
 }}}

 So now 4 of the 10 new tests fail when run on unpatched trunk. The other
 tests succeed without patch because:

 1. For test_append_slash_have_slash_custom_urlconf (line 133), we are
 testing that URLs with slashes go unmolested. So even if we have an
 unknown URL, the test will succeed because we have a slash on the end.

 2. For test_append_slash_slashless_resource_custom_urlconf (line 142), we
 are testing that explicit slashless URLs go unmolested. Again, if unknown
 URL, test will pass because CommonMiddlware will check for the unknown URL
 + '/', which is not valid. Therefore, None is returned and the test
 passes.

 3. For test_append_slash_slashless_unknown_custom_urlconf (line 151). We
 are testing unknown URL. Test passes because of reason given in #2. This
 is expected behavior.

 4. For test_append_slash_disabled_custom_urlconf (line 192), we are
 testing that nothing happens when APPEND_SLASH = False. Test passes
 because this is expected behavior.

 5. For test_prepend_www_custom_urlconf (line 215), test passes because we
 have APPEND_SLASH = False.

 6. For test_prepend_www_append_slash_have_slash_custom_urlconf (line 226),
 we are testing that 'www' is prepended to a url ending with a slash. Test
 passes despite the url being unknown because there is already a slash at
 the end of the URL.


 Updated patch with new tests are attached.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/6228#comment:14>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to