#9921: request.urlconf incorrect behavoir
----------------------------------------+-----------------------------------
          Reporter:  strelnikovdmitrij  |         Owner:  nobody         
            Status:  reopened           |     Milestone:                 
         Component:  Core framework     |       Version:  1.0            
        Resolution:                     |      Keywords:  request.urlconf
             Stage:  Unreviewed         |     Has_patch:  1              
        Needs_docs:  0                  |   Needs_tests:  1              
Needs_better_patch:  0                  |  
----------------------------------------+-----------------------------------
Comment (by strelnikovdmitrij):

 thanks for reply and detail describing ;)
 I've gone through code again :)
 [[BR]]
 The result:
 my changes goes back ;)
 [[BR]]
 now look..
 [[BR]]
 common.py

 {{{
 process_request(self, request):
 ...
 if (not _is_valid_path(request.path_info) and
                     _is_valid_path("%s/" % request.path_info)):
                 new_url[1] = new_url[1] + '/'
 ...
 }}}
 going to _is_valid_path(...

 {{{
 def _is_valid_path(path):
     try:
         urlresolvers.resolve(path)
         return True
     except urlresolvers.Resolver404:
         return False

 }}}
 going to urlresolvers.resolve(path)..
 (file urlresolvers.py)

 {{{
 def resolve(path, urlconf=None): #urlconf is always None (I hope)
     return get_resolver(urlconf).resolve(path)
 }}}

 going to get_resolver(urlconf) # urlconf = None

 {{{
 def get_resolver(urlconf):
     if urlconf is None:
         from django.conf import settings
         urlconf = settings.ROOT_URLCONF #get default settings
     return RegexURLResolver(r'^/', urlconf)
 get_resolver = memoize(get_resolver, _resolver_cache, 1)
 }}}

 I think this should be better..and no operators will changed ;)

 common.py !!! '''+''' means added

 {{{
 def process_request(self, request):
 ...
 host = request.get_host()
 old_url = [host, request.path]
 new_url = old_url[:]

 + urlconf = None +
 ...
 if (not _is_valid_path(request.path_info, +urlconf+) and
                     _is_valid_path("%s/" % request.path_info, +urlconf+)):
                 new_url[1] = new_url[1] + '/'
 }}}
 going to _is_valid_path..

 {{{
 def _is_valid_path(path, +urlconf=None+):
     try:
         urlresolvers.resolve(path, +urlconf+)
         return True
     except urlresolvers.Resolver404:
         return False
 }}}
 and urlresolvers.resolve will get correct urlconf from request, if there
 is no urlconf it will be getted from settings ;)
 [[BR]]

 Any better ideas?
 Thanks.
 Dmitrij

-- 
Ticket URL: <http://code.djangoproject.com/ticket/9921#comment:7>
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to