1 |
arfrever 11/01/25 21:56:04 |
2 |
|
3 |
Added: django-1.2.4-ticket-14576.patch |
4 |
django-1.2.4-python-2.7.patch |
5 |
Log: |
6 |
Fix regression in FormWizard (Django ticket #14576). Fix tests with Python 2.7 (Django ticket #14947). |
7 |
|
8 |
(Portage version: 2.2.0_alpha19_p1/cvs/Linux x86_64) |
9 |
|
10 |
Revision Changes Path |
11 |
1.1 dev-python/django/files/django-1.2.4-ticket-14576.patch |
12 |
|
13 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/django/files/django-1.2.4-ticket-14576.patch?rev=1.1&view=markup |
14 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/django/files/django-1.2.4-ticket-14576.patch?rev=1.1&content-type=text/plain |
15 |
|
16 |
Index: django-1.2.4-ticket-14576.patch |
17 |
=================================================================== |
18 |
http://code.djangoproject.com/ticket/14576 |
19 |
http://code.djangoproject.com/changeset/15044 |
20 |
|
21 |
--- django/contrib/formtools/tests.py |
22 |
+++ django/contrib/formtools/tests.py |
23 |
@@ -116,7 +116,7 @@ |
24 |
hash1 = utils.security_hash(None, f1) |
25 |
hash2 = utils.security_hash(None, f2) |
26 |
self.assertEqual(hash1, hash2) |
27 |
- |
28 |
+ |
29 |
def test_empty_permitted(self): |
30 |
""" |
31 |
Regression test for #10643: the security hash should allow forms with |
32 |
@@ -214,3 +214,26 @@ |
33 |
wizard(DummyRequest(POST=data)) |
34 |
self.assertTrue(reached[0]) |
35 |
|
36 |
+ def test_14576(self): |
37 |
+ """ |
38 |
+ Regression test for ticket #14576. |
39 |
+ |
40 |
+ The form of the last step is not passed to the done method. |
41 |
+ """ |
42 |
+ reached = [False] |
43 |
+ that = self |
44 |
+ |
45 |
+ class Wizard(WizardClass): |
46 |
+ def done(self, request, form_list): |
47 |
+ reached[0] = True |
48 |
+ that.assertTrue(len(form_list) == 2) |
49 |
+ |
50 |
+ wizard = Wizard([WizardPageOneForm, |
51 |
+ WizardPageTwoForm]) |
52 |
+ |
53 |
+ data = {"0-field": "test", |
54 |
+ "1-field": "test2", |
55 |
+ "hash_0": "2fdbefd4c0cad51509478fbacddf8b13", |
56 |
+ "wizard_step": "1"} |
57 |
+ wizard(DummyRequest(POST=data)) |
58 |
+ self.assertTrue(reached[0]) |
59 |
--- django/contrib/formtools/wizard.py |
60 |
+++ django/contrib/formtools/wizard.py |
61 |
@@ -94,9 +94,9 @@ |
62 |
# Since the hashes only take into account values, and not other |
63 |
# other validation the form might do, we must re-do validation |
64 |
# now for security reasons. |
65 |
- current_form_list = [self.get_form(i, request.POST) for i in range(current_step)] |
66 |
+ previous_form_list = [self.get_form(i, request.POST) for i in range(current_step)] |
67 |
|
68 |
- for i, f in enumerate(current_form_list): |
69 |
+ for i, f in enumerate(previous_form_list): |
70 |
if request.POST.get("hash_%d" % i, '') != self.security_hash(request, f): |
71 |
return self.render_hash_failure(request, i) |
72 |
|
73 |
@@ -111,7 +111,7 @@ |
74 |
|
75 |
|
76 |
if next_step == self.num_steps(): |
77 |
- return self.done(request, current_form_list) |
78 |
+ return self.done(request, previous_form_list + [form]) |
79 |
else: |
80 |
form = self.get_form(next_step) |
81 |
self.step = current_step = next_step |
82 |
|
83 |
|
84 |
|
85 |
1.1 dev-python/django/files/django-1.2.4-python-2.7.patch |
86 |
|
87 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/django/files/django-1.2.4-python-2.7.patch?rev=1.1&view=markup |
88 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/django/files/django-1.2.4-python-2.7.patch?rev=1.1&content-type=text/plain |
89 |
|
90 |
Index: django-1.2.4-python-2.7.patch |
91 |
=================================================================== |
92 |
http://code.djangoproject.com/ticket/14947 |
93 |
http://code.djangoproject.com/changeset/15165 |
94 |
|
95 |
--- tests/regressiontests/fixtures_regress/tests.py |
96 |
+++ tests/regressiontests/fixtures_regress/tests.py |
97 |
@@ -1,6 +1,7 @@ |
98 |
# -*- coding: utf-8 -*- |
99 |
# Unittests for fixtures. |
100 |
import os |
101 |
+import re |
102 |
import sys |
103 |
try: |
104 |
from cStringIO import StringIO |
105 |
@@ -327,9 +328,14 @@ |
106 |
|
107 |
# Output order isn't guaranteed, so check for parts |
108 |
data = stdout.getvalue() |
109 |
+ |
110 |
+ # Get rid of artifacts like '000000002' to eliminate the differences |
111 |
+ # between different Python versions. |
112 |
+ data = re.sub('0{6,}\d', '', data) |
113 |
+ |
114 |
lion_json = '{"pk": 1, "model": "fixtures_regress.animal", "fields": {"count": 3, "weight": 1.2, "name": "Lion", "latin_name": "Panthera leo"}}' |
115 |
emu_json = '{"pk": 10, "model": "fixtures_regress.animal", "fields": {"count": 42, "weight": 1.2, "name": "Emu", "latin_name": "Dromaius novaehollandiae"}}' |
116 |
- platypus_json = '{"pk": %d, "model": "fixtures_regress.animal", "fields": {"count": 2, "weight": 2.2000000000000002, "name": "Platypus", "latin_name": "Ornithorhynchus anatinus"}}' |
117 |
+ platypus_json = '{"pk": %d, "model": "fixtures_regress.animal", "fields": {"count": 2, "weight": 2.2, "name": "Platypus", "latin_name": "Ornithorhynchus anatinus"}}' |
118 |
platypus_json = platypus_json % animal.pk |
119 |
|
120 |
self.assertEqual(len(data), len('[%s]' % ', '.join([lion_json, emu_json, platypus_json]))) |