Ticket #285: script_name_path_info2.diff
File script_name_path_info2.diff, 15.4 KB (added by , 17 years ago) |
---|
-
django/http/__init__.py
26 26 def __init__(self): 27 27 self.GET, self.POST, self.COOKIES, self.META, self.FILES = {}, {}, {}, {}, {} 28 28 self.path = '' 29 self.full_path = '' 29 30 self.method = None 30 31 31 32 def __repr__(self): … … 57 58 location = self.get_full_path() 58 59 if not ':' in location: 59 60 current_uri = '%s://%s%s' % (self.is_secure() and 'https' or 'http', 60 get_host(self), self. path)61 get_host(self), self.full_path) 61 62 location = urljoin(current_uri, location) 62 63 return location 63 64 -
django/core/handlers/wsgi.py
75 75 class WSGIRequest(http.HttpRequest): 76 76 def __init__(self, environ): 77 77 self.environ = environ 78 self.path = force_unicode(environ['PATH_INFO']) 78 self.path = force_unicode(environ.get('PATH_INFO', '/')) 79 self.full_path = (force_unicode(environ.get('SCRIPT_NAME', '')) 80 + force_unicode(environ.get('PATH_INFO', '/'))) 79 81 self.META = environ 80 82 self.method = environ['REQUEST_METHOD'].upper() 81 83 … … 102 104 (get, post, cookies, meta) 103 105 104 106 def get_full_path(self): 105 return '%s%s' % (self. path, self.environ.get('QUERY_STRING', '') and ('?' + self.environ.get('QUERY_STRING', '')) or '')107 return '%s%s' % (self.full_path, self.environ.get('QUERY_STRING', '') and ('?' + self.environ.get('QUERY_STRING', '')) or '') 106 108 107 109 def is_secure(self): 108 110 return 'HTTPS' in self.environ and self.environ['HTTPS'] == 'on' -
django/core/handlers/modpython.py
14 14 class ModPythonRequest(http.HttpRequest): 15 15 def __init__(self, req): 16 16 self._req = req 17 self.path = force_unicode(req.uri) 17 self.full_path = force_unicode(req.uri) 18 root = req.get_options().get('django.root', '') 19 if root and req.uri.startswith(root): 20 self.path = force_unicode(req.uri[len(root):]) 21 else: 22 self.path = self.full_path 18 23 19 24 def __repr__(self): 20 25 # Since this is called as part of error handling, we need to be very … … 39 44 (self.path, get, post, cookies, meta) 40 45 41 46 def get_full_path(self): 42 return '%s%s' % (self. path, self._req.args and ('?' + self._req.args) or '')47 return '%s%s' % (self.full_path, self._req.args and ('?' + self._req.args) or '') 43 48 44 49 def is_secure(self): 45 50 # Note: modpython 3.2.10+ has req.is_https(), but we need to support previous versions -
django/views/generic/create_update.py
21 21 """ 22 22 if extra_context is None: extra_context = {} 23 23 if login_required and not request.user.is_authenticated(): 24 return redirect_to_login(request. path)24 return redirect_to_login(request.full_path) 25 25 26 26 manipulator = model.AddManipulator(follow=follow) 27 27 if request.POST: … … 87 87 """ 88 88 if extra_context is None: extra_context = {} 89 89 if login_required and not request.user.is_authenticated(): 90 return redirect_to_login(request. path)90 return redirect_to_login(request.full_path) 91 91 92 92 # Look up the object to be edited 93 93 lookup_kwargs = {} … … 163 163 """ 164 164 if extra_context is None: extra_context = {} 165 165 if login_required and not request.user.is_authenticated(): 166 return redirect_to_login(request. path)166 return redirect_to_login(request.full_path) 167 167 168 168 # Look up the object to be edited 169 169 lookup_kwargs = {} -
django/views/debug.py
345 345 </tr> 346 346 <tr> 347 347 <th>Request URL:</th> 348 <td>{{ request_protocol }}://{{ request.META.HTTP_HOST }}{{ request. path|escape }}</td>348 <td>{{ request_protocol }}://{{ request.META.HTTP_HOST }}{{ request.full_path|escape }}</td> 349 349 </tr> 350 350 <tr> 351 351 <th>Exception Type:</th> … … 634 634 </tr> 635 635 <tr> 636 636 <th>Request URL:</th> 637 <td>{{ request_protocol }}://{{ request.META.HTTP_HOST }}{{ request. path|escape }}</td>637 <td>{{ request_protocol }}://{{ request.META.HTTP_HOST }}{{ request.full_path|escape }}</td> 638 638 </tr> 639 639 </table> 640 640 </div> -
django/contrib/syndication/feeds.py
25 25 def __init__(self, slug, request): 26 26 self.slug = slug 27 27 self.request = request 28 self.feed_url = request. path28 self.feed_url = request.full_path 29 29 self.title_template_name = self.title_template or ('feeds/%s_title.html' % slug) 30 30 self.description_template_name = self.description_template or ('feeds/%s_description.html' % slug) 31 31 -
django/contrib/comments/views/userflags.py
19 19 comment = get_object_or_404(Comment,pk=comment_id, site__id__exact=settings.SITE_ID) 20 20 if request.POST: 21 21 UserFlag.objects.flag(comment, request.user) 22 return HttpResponseRedirect('%sdone/' % request. path)22 return HttpResponseRedirect('%sdone/' % request.full_path) 23 23 return render_to_response('comments/flag_verify.html', {'comment': comment}, 24 24 context_instance=RequestContext(request, extra_context, context_processors)) 25 25 flag = login_required(flag) … … 50 50 comment.save() 51 51 m = ModeratorDeletion(None, request.user.id, comment.id, None) 52 52 m.save() 53 return HttpResponseRedirect('%sdone/' % request. path)53 return HttpResponseRedirect('%sdone/' % request.full_path) 54 54 return render_to_response('comments/delete_verify.html', {'comment': comment}, 55 55 context_instance=RequestContext(request, extra_context, context_processors)) 56 56 delete = login_required(delete) -
django/contrib/admin/views/auth.py
20 20 msg = _('The %(name)s "%(obj)s" was added successfully.') % {'name': 'user', 'obj': new_user} 21 21 if "_addanother" in request.POST: 22 22 request.user.message_set.create(message=msg) 23 return HttpResponseRedirect(request. path)23 return HttpResponseRedirect(request.full_path) 24 24 else: 25 25 request.user.message_set.create(message=msg + ' ' + _("You may edit it again below.")) 26 26 return HttpResponseRedirect('../%s/' % new_user.id) -
django/contrib/admin/views/main.py
276 276 (pk_value, force_unicode(new_object).replace('"', '\\"'))) 277 277 elif "_addanother" in request.POST: 278 278 request.user.message_set.create(message=msg + ' ' + (_("You may add another %s below.") % force_unicode(opts.verbose_name))) 279 return HttpResponseRedirect(request. path)279 return HttpResponseRedirect(request.full_path) 280 280 else: 281 281 request.user.message_set.create(message=msg) 282 282 return HttpResponseRedirect(post_url) … … 353 353 if "_continue" in request.POST: 354 354 request.user.message_set.create(message=msg + ' ' + _("You may edit it again below.")) 355 355 if '_popup' in request.REQUEST: 356 return HttpResponseRedirect(request. path + "?_popup=1")356 return HttpResponseRedirect(request.full_path + "?_popup=1") 357 357 else: 358 return HttpResponseRedirect(request. path)358 return HttpResponseRedirect(request.full_path) 359 359 elif "_saveasnew" in request.POST: 360 360 request.user.message_set.create(message=_('The %(name)s "%(obj)s" was added successfully. You may edit it again below.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(new_object)}) 361 361 return HttpResponseRedirect("../%s/" % pk_value) … … 778 778 # is screwed up with the database, so display an error page. 779 779 if ERROR_FLAG in request.GET.keys(): 780 780 return render_to_response('admin/invalid_setup.html', {'title': _('Database error')}) 781 return HttpResponseRedirect(request. path + '?' + ERROR_FLAG + '=1')781 return HttpResponseRedirect(request.full_path + '?' + ERROR_FLAG + '=1') 782 782 c = template.RequestContext(request, { 783 783 'title': cl.title, 784 784 'is_popup': cl.is_popup, -
django/contrib/admin/views/decorators.py
22 22 post_data = _encode_post_data({}) 23 23 return render_to_response('admin/login.html', { 24 24 'title': _('Log in'), 25 'app_path': request. path,25 'app_path': request.full_path, 26 26 'post_data': post_data, 27 27 'error_message': error_message 28 28 }, context_instance=template.RequestContext(request)) … … 99 99 return view_func(request, *args, **kwargs) 100 100 else: 101 101 request.session.delete_test_cookie() 102 return http.HttpResponseRedirect(request. path)102 return http.HttpResponseRedirect(request.full_path) 103 103 else: 104 104 return _display_login_form(request, ERROR_MESSAGE) 105 105 -
django/contrib/admin/views/doc.py
27 27 28 28 def bookmarklets(request): 29 29 # Hack! This couples this view to the URL it lives at. 30 admin_root = request. path[:-len('doc/bookmarklets/')]30 admin_root = request.full_path[:-len('doc/bookmarklets/')] 31 31 return render_to_response('admin_doc/bookmarklets.html', { 32 32 'admin_url': "%s://%s%s" % (request.is_secure() and 'https' or 'http', get_host(request), admin_root), 33 33 }, context_instance=RequestContext(request)) -
django/contrib/databrowse/plugins/objects.py
8 8 def model_view(self, request, model_databrowse, url): 9 9 # If the object ID wasn't provided, redirect to the model page, which is one level up. 10 10 if url is None: 11 return http.HttpResponseRedirect(urlparse.urljoin(request. path, '../'))11 return http.HttpResponseRedirect(urlparse.urljoin(request.full_path, '../')) 12 12 easy_model = EasyModel(model_databrowse.site, model_databrowse.model) 13 13 obj = easy_model.object_by_pk(url) 14 14 return render_to_response('databrowse/object_detail.html', {'object': obj, 'root_url': model_databrowse.site.root_url}) -
django/contrib/databrowse/sites.py
110 110 111 111 `url` is the remainder of the URL -- e.g. 'comments/comment/'. 112 112 """ 113 self.root_url = request. path[:len(request.path) - len(url)]113 self.root_url = request.full_path[:len(request.full_path) - len(url)] 114 114 url = url.rstrip('/') # Trim trailing slash, if it exists. 115 115 116 116 if url == '': -
django/contrib/auth/views.py
47 47 return render_to_response(template_name, {'title': _('Logged out')}, context_instance=RequestContext(request)) 48 48 else: 49 49 # Redirect to this page until the session has been cleared. 50 return HttpResponseRedirect(next_page or request. path)50 return HttpResponseRedirect(next_page or request.full_path) 51 51 52 52 def logout_then_login(request, login_url=None): 53 53 "Logs out the user if he is logged in. Then redirects to the log-in page." … … 75 75 form.save(domain_override=request.META['HTTP_HOST']) 76 76 else: 77 77 form.save(email_template_name=email_template_name) 78 return HttpResponseRedirect('%sdone/' % request. path)78 return HttpResponseRedirect('%sdone/' % request.full_path) 79 79 return render_to_response(template_name, {'form': oldforms.FormWrapper(form, new_data, errors)}, 80 80 context_instance=RequestContext(request)) 81 81 … … 90 90 errors = form.get_validation_errors(new_data) 91 91 if not errors: 92 92 form.save(new_data) 93 return HttpResponseRedirect('%sdone/' % request. path)93 return HttpResponseRedirect('%sdone/' % request.full_path) 94 94 return render_to_response(template_name, {'form': oldforms.FormWrapper(form, new_data, errors)}, 95 95 context_instance=RequestContext(request)) 96 96 password_change = login_required(password_change) -
django/contrib/flatpages/views.py
25 25 # logged in, redirect to the login page. 26 26 if f.registration_required and not request.user.is_authenticated(): 27 27 from django.contrib.auth.views import redirect_to_login 28 return redirect_to_login(request. path)28 return redirect_to_login(request.full_path) 29 29 if f.template_name: 30 30 t = loader.select_template((f.template_name, DEFAULT_TEMPLATE)) 31 31 else: -
django/middleware/common.py
33 33 34 34 # Check for a redirect based on settings.APPEND_SLASH and settings.PREPEND_WWW 35 35 host = http.get_host(request) 36 old_url = [host, request. path]36 old_url = [host, request.full_path] 37 37 new_url = old_url[:] 38 38 if settings.PREPEND_WWW and old_url[0] and not old_url[0].startswith('www.'): 39 39 new_url[0] = 'www.' + old_url[0]