Fixed #18314.request.build_absolute_uri() finally functions correctly #1314

Closed
wants to merge 15 commits into from
@ArcTanSusan

https://code.djangoproject.com/ticket/18314 In "django/http", request.build_absolute_uri() finally functions correctly when path starts with "//". Thanks SmileyChris and yoyoma for work on the patches. I manually applied the "18314.diff" patch given by SmileyChris. The tests in "tests/http/" failed before the patch was implemented, and then the tests succeeded after the patch was implemented. Please code review and let me know how I can make this PR better.

mjtamlyn and others added some commits Jun 22, 2013
@mjtamlyn mjtamlyn Merge pull request #1294 from LuRsT/added_prefix_to_form_mixin
Fixed #18872 -- Added prefix to FormMixin
257a137
@andrewgodwin andrewgodwin Merge pull request #1295 from LuRsT/fix_sqlite_convert_values_20587
Fixed #20587 -- Made convert_values handle None values
864613c
@charettes charettes Added missing `versionadded` for `FormMixin.prefix`. ecf63d5
@ramiro ramiro Fixed #20311 -- Make sure makemessages doesn't create duplicate Plura…
…l-Forms .po file headers.

Thanks naktinis for the report and initial patch.
1559f84
@shanx shanx Fixed a very old email address of mine still lingering in the AUTHORS…
… file
338ec93
@bmispelon bmispelon Fixed errors and inconsistencies in CBV topic documentation.
The code examples should now work correctly.
The `get_context_data` method in the examples was changed when
necessary to adopt a singular style (get context with super(...),
add the extra keys to the dict then return it).

Thanks to Remco Wendt for the initial report and to Tim Graham
for the review.
bd9fbd1
@ArcTanSusan ArcTanSusan Fixed #20524 - Described keywords in triaging contrib doc. b0907d6
@DrMeers DrMeers Corrected minor typos in FileUploadHandler.receive_data_chunk docs. 6466a08
@bmispelon bmispelon Fixed #20643 -- Fixed implementation of JSONResponseMixin in CBV docs
Thanks to Michal Sládek for the report and initial patch,
and to loic84 for the review.
cd000da
@bmispelon bmispelon Fixed #20644 -- Add ModelFormMixin.fields to the CBV flattened index
Thanks to Tim Graham for the report and review.
2999836
@timgraham timgraham Clarified get_list_or_404 docs, refs #14150. e161e4f
@aaugustin aaugustin Fixed #20636 -- Stopped stuffing values in the settings.
In Django < 1.6, override_settings restores the settings module that was
active when the override_settings call was executed, not when it was
run. This can make a difference when override_settings is applied to a
class, since it's executed when the module is imported, not when the
test case is run.

In addition, if the settings module for tests is stored alongside the
tests themselves, importing the settings module can trigger an import
of the tests. Since the settings module isn't fully imported yet,
class-level override_settings statements may store a reference to an
incorrect settings module. Eventually this will result in a crash during
test teardown because the settings module restored by override_settings
won't the one that was active during test setup.

While Django should prevent this situation in the future by failing
loudly in such dubious import sequences, that change won't be backported
to 1.5 and 1.4. However, these versions received the "allowed hosts"
patch and they're prone to "AttributeError: 'Settings' object has no
attribute '_original_allowed_hosts'". To mitigate this regression, this
commits stuffs _original_allowed_hosts on a random module instead of the
settings module.

This problem shouldn't occur in Django 1.6, see #20290, but this patch
will be forward-ported for extra safety.

Also tweaked backup variable names for consistency.

Forward port of 0261922 from stable/1.5.x.

Conflicts:
	django/test/utils.py
5a6f121
@freakboy3742 freakboy3742 Fixed #20653 -- Renamed checksetup management command.
This is to allow future compatibility with work that is ongoing in the 2013 GSoC.
0346563
@izquierdo izquierdo Fixed #20654 -- Fixed type of `m2m_changed`'s `pk_set` arg in docs 9a2b07f
@ArcTanSusan ArcTanSusan Fixed #18314.request.build_absolute_uri() finally functions correctly…
… when the path starts with //
92c9866
@timgraham
Django member

this doesn't fail for me, did you fix it?

I do get some other failures though:

======================================================================
FAIL: test_https_login_url (django.contrib.auth.tests.test_views.LoginURLSettings)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/timgraham/code/django/django/test/utils.py", line 220, in inner
    return test_func(*args, **kwargs)
  File "/home/timgraham/code/django/django/contrib/auth/tests/test_views.py", line 558, in test_https_login_url
    self.assertLoginURLEquals(expected)
  File "/home/timgraham/code/django/django/contrib/auth/tests/test_views.py", line 538, in assertLoginURLEquals
    self.assertURLEqual(response.url, url, parse_qs=parse_qs)
  File "/home/timgraham/code/django/django/contrib/auth/tests/test_views.py", line 83, in assertURLEqual
    self.fail("%r != %r (%s doesn't match)" % (url, expected, attr))
AssertionError: 'https:///login/?next=http%3A//testserver//login_required/' != u'https:///login/?next=http%3A//testserver/login_required/' (query doesn't match)

======================================================================
FAIL: test_remote_login_url (django.contrib.auth.tests.test_views.LoginURLSettings)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/timgraham/code/django/django/test/utils.py", line 220, in inner
    return test_func(*args, **kwargs)
  File "/home/timgraham/code/django/django/contrib/auth/tests/test_views.py", line 552, in test_remote_login_url
    self.assertLoginURLEquals(expected)
  File "/home/timgraham/code/django/django/contrib/auth/tests/test_views.py", line 538, in assertLoginURLEquals
    self.assertURLEqual(response.url, url, parse_qs=parse_qs)
  File "/home/timgraham/code/django/django/contrib/auth/tests/test_views.py", line 83, in assertURLEqual
    self.fail("%r != %r (%s doesn't match)" % (url, expected, attr))
AssertionError: 'http://remote.example.com/login?next=http%3A//testserver//login_required/' != u'http://remote.example.com/login?next=http%3A//testserver/login_required/' (query doesn't match)

======================================================================
FAIL: test_remote_login_url_with_next_querystring (django.contrib.auth.tests.test_views.LoginURLSettings)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/timgraham/code/django/django/test/utils.py", line 220, in inner
    return test_func(*args, **kwargs)
  File "/home/timgraham/code/django/django/contrib/auth/tests/test_views.py", line 568, in test_remote_login_url_with_next_querystring
    self.assertLoginURLEquals(expected)
  File "/home/timgraham/code/django/django/contrib/auth/tests/test_views.py", line 538, in assertLoginURLEquals
    self.assertURLEqual(response.url, url, parse_qs=parse_qs)
  File "/home/timgraham/code/django/django/contrib/auth/tests/test_views.py", line 83, in assertURLEqual
    self.fail("%r != %r (%s doesn't match)" % (url, expected, attr))
AssertionError: 'http://remote.example.com/login/?next=http%3A//testserver//login_required/' != u'http://remote.example.com/login/?next=http%3A//testserver/login_required/' (query doesn't match)
@timgraham
Django member

Please open a new PR if you can fix the tests, thanks.

@timgraham timgraham closed this Sep 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment