diff --git a/django/contrib/sessions/tests.py b/django/contrib/sessions/tests.py
index 89bcce8..dbcaea2 100644
a
|
b
|
class SessionMiddlewareTests(unittest.TestCase):
|
407 | 407 | |
408 | 408 | # Handle the response through the middleware |
409 | 409 | response = middleware.process_response(request, response) |
410 | | # If it isn't in the cookie, that's fine (Python 2.5) |
411 | | if 'httponly' in settings.SESSION_COOKIE_NAME: |
412 | | self.assertFalse( |
413 | | response.cookies[settings.SESSION_COOKIE_NAME]['httponly']) |
| 410 | self.assertFalse(response.cookies[settings.SESSION_COOKIE_NAME]['httponly']) |
414 | 411 | |
415 | 412 | self.assertNotIn('httponly', |
416 | 413 | str(response.cookies[settings.SESSION_COOKIE_NAME])) |
diff --git a/django/core/cache/__init__.py b/django/core/cache/__init__.py
index 346deae..9eac8ec 100644
a
|
b
|
try:
|
25 | 25 | # The mod_python version is more efficient, so try importing it first. |
26 | 26 | from mod_python.util import parse_qsl |
27 | 27 | except ImportError: |
28 | | try: |
29 | | # Python 2.6 and greater |
30 | | from urlparse import parse_qsl |
31 | | except ImportError: |
32 | | # Python 2.5. Works on Python 2.6 but raises PendingDeprecationWarning |
33 | | from cgi import parse_qsl |
| 28 | from urlparse import parse_qsl |
34 | 29 | |
35 | 30 | __all__ = [ |
36 | 31 | 'get_cache', 'cache', 'DEFAULT_CACHE_ALIAS' |
diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py
index 3e5b758..2f1775e 100644
a
|
b
|
from django.core.management.color import no_style
|
12 | 12 | from django.db import (connections, router, transaction, DEFAULT_DB_ALIAS, |
13 | 13 | IntegrityError, DatabaseError) |
14 | 14 | from django.db.models import get_apps |
15 | | from django.utils.itercompat import product |
| 15 | from itertools import product |
16 | 16 | |
17 | 17 | try: |
18 | 18 | import bz2 |
diff --git a/django/http/__init__.py b/django/http/__init__.py
index 94478ae..5f407a4 100644
a
|
b
|
try:
|
18 | 18 | # The mod_python version is more efficient, so try importing it first. |
19 | 19 | from mod_python.util import parse_qsl |
20 | 20 | except ImportError: |
21 | | try: |
22 | | # Python 2.6 and greater |
23 | | from urlparse import parse_qsl |
24 | | except ImportError: |
25 | | # Python 2.5. Works on Python 2.6 but raises PendingDeprecationWarning |
26 | | from cgi import parse_qsl |
| 21 | from urlparse import parse_qsl |
27 | 22 | |
28 | 23 | import Cookie |
29 | | # httponly support exists in Python 2.6's Cookie library, |
30 | | # but not in Python 2.5. |
31 | | _morsel_supports_httponly = 'httponly' in Cookie.Morsel._reserved |
32 | 24 | # Some versions of Python 2.7 and later won't need this encoding bug fix: |
33 | 25 | _cookie_encodes_correctly = Cookie.SimpleCookie().value_encode(';') == (';', '"\\073"') |
34 | 26 | # See ticket #13007, http://bugs.python.org/issue2193 and http://trac.edgewall.org/ticket/2256 |
… |
… |
try:
|
39 | 31 | except Cookie.CookieError: |
40 | 32 | _cookie_allows_colon_in_names = False |
41 | 33 | |
42 | | if _morsel_supports_httponly and _cookie_encodes_correctly and _cookie_allows_colon_in_names: |
| 34 | if _cookie_encodes_correctly and _cookie_allows_colon_in_names: |
43 | 35 | SimpleCookie = Cookie.SimpleCookie |
44 | 36 | else: |
45 | | if not _morsel_supports_httponly: |
46 | | class Morsel(Cookie.Morsel): |
47 | | def __setitem__(self, K, V): |
48 | | K = K.lower() |
49 | | if K == "httponly": |
50 | | if V: |
51 | | # The superclass rejects httponly as a key, |
52 | | # so we jump to the grandparent. |
53 | | super(Cookie.Morsel, self).__setitem__(K, V) |
54 | | else: |
55 | | super(Morsel, self).__setitem__(K, V) |
56 | | |
57 | | def OutputString(self, attrs=None): |
58 | | output = super(Morsel, self).OutputString(attrs) |
59 | | if "httponly" in self: |
60 | | output += "; httponly" |
61 | | return output |
62 | | else: |
63 | | Morsel = Cookie.Morsel |
| 37 | Morsel = Cookie.Morsel |
64 | 38 | |
65 | 39 | class SimpleCookie(Cookie.SimpleCookie): |
66 | 40 | if not _cookie_encodes_correctly: |
… |
… |
else:
|
88 | 62 | |
89 | 63 | return val, encoded |
90 | 64 | |
91 | | if not _cookie_allows_colon_in_names or not _morsel_supports_httponly: |
| 65 | if not _cookie_allows_colon_in_names: |
92 | 66 | def load(self, rawdata): |
93 | 67 | self.bad_cookies = set() |
94 | 68 | super(SimpleCookie, self).load(rawdata) |
diff --git a/django/utils/itercompat.py b/django/utils/itercompat.py
index 82434b7..bc6f0fa 100644
a
|
b
|
these implementations if necessary.
|
5 | 5 | """ |
6 | 6 | |
7 | 7 | import __builtin__ |
8 | | import itertools |
9 | 8 | import warnings |
10 | 9 | |
11 | | # Fallback for Python 2.5 |
12 | | def product(*args, **kwds): |
13 | | """ |
14 | | Taken from http://docs.python.org/library/itertools.html#itertools.product |
15 | | """ |
16 | | # product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy |
17 | | # product(range(2), repeat=3) --> 000 001 010 011 100 101 110 111 |
18 | | pools = map(tuple, args) * kwds.get('repeat', 1) |
19 | | result = [[]] |
20 | | for pool in pools: |
21 | | result = [x+[y] for x in result for y in pool] |
22 | | for prod in result: |
23 | | yield tuple(prod) |
24 | | |
25 | | if hasattr(itertools, 'product'): |
26 | | product = itertools.product |
27 | | |
28 | 10 | def is_iterable(x): |
29 | 11 | "A implementation independent way of checking for iterables" |
30 | 12 | try: |
… |
… |
def is_iterable(x):
|
34 | 16 | else: |
35 | 17 | return True |
36 | 18 | |
| 19 | def product(*args, **kwds): |
| 20 | # PendingDeprecationWarning in 1.5, remove this comment when the Deprecations |
| 21 | # will have been advanced for 1.5 |
| 22 | warnings.warn("django.utils.itercompat.product is deprecated; use the native version instead", |
| 23 | PendingDeprecationWarning) |
| 24 | return __builtin__.product(*args, **kwds) |
| 25 | |
37 | 26 | def all(iterable): |
38 | 27 | warnings.warn("django.utils.itercompat.all is deprecated; use the native version instead", |
39 | 28 | PendingDeprecationWarning) |
diff --git a/docs/faq/install.txt b/docs/faq/install.txt
index c5847d3..8021229 100644
a
|
b
|
How do I get started?
|
16 | 16 | What are Django's prerequisites? |
17 | 17 | -------------------------------- |
18 | 18 | |
19 | | Django requires Python_, specifically any version of Python from 2.5 |
| 19 | Django requires Python_, specifically any version of Python from 2.6 |
20 | 20 | through 2.7. No other Python libraries are required for basic Django |
21 | 21 | usage. |
22 | 22 | |
… |
… |
PostgreSQL fans, and MySQL_, `SQLite 3`_, and Oracle_ are also supported.
|
39 | 39 | .. _`SQLite 3`: http://www.sqlite.org/ |
40 | 40 | .. _Oracle: http://www.oracle.com/ |
41 | 41 | |
42 | | Do I lose anything by using Python 2.5 versus newer Python versions, such as Python 2.6 or 2.7? |
43 | | ----------------------------------------------------------------------------------------------- |
| 42 | Do I lose anything by using Python 2.6 versus newer Python versions, such as Python 2.7? |
| 43 | ---------------------------------------------------------------------------------------- |
44 | 44 | |
45 | 45 | Not in the core framework. Currently, Django itself officially supports any |
46 | | version of Python from 2.5 through 2.7, inclusive. However, newer versions of |
| 46 | version of Python from 2.6 through 2.7, inclusive. However, newer versions of |
47 | 47 | Python are often faster, have more features, and are better supported. If you |
48 | 48 | use a newer version of Python you will also have access to some APIs that |
49 | | aren't available under older versions of Python. For example, since Python 2.6, |
50 | | you can use the advanced string formatting described in :pep:`3101`. |
| 49 | aren't available under older versions of Python. |
51 | 50 | |
52 | 51 | Third-party applications for use with Django are, of course, free to set their |
53 | 52 | own version requirements. |
… |
… |
versions as part of a migration which will end with Django running on Python 3
|
58 | 57 | |
59 | 58 | All else being equal, we recommend that you use the latest 2.x release |
60 | 59 | (currently Python 2.7). This will let you take advantage of the numerous |
61 | | improvements and optimizations to the Python language since version 2.5, and |
| 60 | improvements and optimizations to the Python language since version 2.6, and |
62 | 61 | will help ease the process of dropping support for older Python versions on |
63 | 62 | the road to Python 3. |
64 | 63 | |
diff --git a/docs/howto/jython.txt b/docs/howto/jython.txt
index 68f8378..5b11a88 100644
a
|
b
|
Running Django on Jython
|
4 | 4 | |
5 | 5 | .. index:: Jython, Java, JVM |
6 | 6 | |
| 7 | .. admonition:: |
| 8 | |
| 9 | Django 1.5 has dropped support for Python 2.5. Until Jython provides a new |
| 10 | version that supports 2.6, Django 1.5 is no more compatible with Jython. |
| 11 | Please use Django 1.4 if you want to use Django over Jython. |
| 12 | |
7 | 13 | Jython_ is an implementation of Python that runs on the Java platform (JVM). |
8 | 14 | Django runs cleanly on Jython version 2.5 or later, which means you can deploy |
9 | 15 | Django on any Java platform. |
diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt
index 81ca7af..66791e6 100644
a
|
b
|
in a backward incompatible way, following their deprecation, as per the
|
7 | 7 | :ref:`deprecation policy <internal-release-deprecation-policy>`. More details |
8 | 8 | about each item can often be found in the release notes of two versions prior. |
9 | 9 | |
10 | | 1.3 |
11 | | --- |
12 | | |
13 | | See the :doc:`Django 1.1 release notes</releases/1.1>` for more details on |
14 | | these changes. |
15 | | |
16 | | * ``AdminSite.root()``. This method of hooking up the admin URLs will be |
17 | | removed in favor of including ``admin.site.urls``. |
18 | | |
19 | | * Authentication backends need to define the boolean attributes |
20 | | ``supports_object_permissions`` and ``supports_anonymous_user`` until |
21 | | version 1.4, at which point it will be assumed that all backends will |
22 | | support these options. |
23 | | |
24 | 10 | 1.4 |
25 | 11 | --- |
26 | 12 | |
… |
… |
these changes.
|
276 | 262 | in 1.4. The backward compatibility will be removed -- |
277 | 263 | ``HttpRequest.raw_post_data`` will no longer work. |
278 | 264 | |
| 265 | 1.7 |
| 266 | --- |
| 267 | |
| 268 | See the :doc:`Django 1.5 release notes</releases/1.5>` for more details on |
| 269 | these changes. |
| 270 | |
| 271 | * The function ``django.utils.itercompat.product`` will be removed. The Python |
| 272 | builtin version should be used instead. |
| 273 | |
279 | 274 | 2.0 |
280 | 275 | --- |
281 | 276 | |
diff --git a/docs/intro/install.txt b/docs/intro/install.txt
index 1efd182..ef04eba 100644
a
|
b
|
Install Python
|
10 | 10 | -------------- |
11 | 11 | |
12 | 12 | Being a Python Web framework, Django requires Python. It works with any Python |
13 | | version from 2.5 to 2.7 (due to backwards incompatibilities in Python 3.0, |
| 13 | version from 2.6 to 2.7 (due to backwards incompatibilities in Python 3.0, |
14 | 14 | Django does not currently work with Python 3.0; see :doc:`the Django FAQ |
15 | 15 | </faq/install>` for more information on supported Python versions and the 3.0 |
16 | 16 | transition), these versions of Python include a lightweight database called |
… |
… |
probably already have it installed.
|
31 | 31 | You can verify that Python is installed by typing ``python`` from your shell; |
32 | 32 | you should see something like:: |
33 | 33 | |
34 | | Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) |
35 | | [GCC 4.0.1 (Apple Inc. build 5465)] on darwin |
| 34 | Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) |
| 35 | [GCC 4.4.5] on linux2 |
36 | 36 | Type "help", "copyright", "credits" or "license" for more information. |
37 | 37 | >>> |
38 | 38 | |
39 | 39 | Set up a database |
40 | 40 | ----------------- |
41 | 41 | |
42 | | If you installed Python 2.5 or later, you can skip this step for now. |
| 42 | If you installed Python 2.6 or later, you can skip this step for now. |
43 | 43 | |
44 | 44 | If not, or if you'd like to work with a "large" database engine like PostgreSQL, |
45 | 45 | MySQL, or Oracle, consult the :ref:`database installation information |
diff --git a/docs/intro/tutorial01.txt b/docs/intro/tutorial01.txt
index d375640..7575afd 100644
a
|
b
|
your database connection settings.
|
221 | 221 | |
222 | 222 | If you're new to databases, we recommend simply using SQLite by setting |
223 | 223 | :setting:`ENGINE` to ``'django.db.backends.sqlite3'`` and :setting:`NAME` to |
224 | | the place where you'd like to store the database. SQLite is included as part |
225 | | of Python 2.5 and later, so you won't need to install anything else to support |
226 | | your database. |
| 224 | the place where you'd like to store the database. SQLite is included in Python, |
| 225 | so you won't need to install anything else to support your database. |
227 | 226 | |
228 | 227 | .. note:: |
229 | 228 | |
diff --git a/docs/ref/contrib/gis/deployment.txt b/docs/ref/contrib/gis/deployment.txt
index 4cea022..c50a378 100644
a
|
b
|
Example::
|
37 | 37 | WSGIProcessGroup geodjango |
38 | 38 | WSGIScriptAlias / /home/geo/geodjango/world.wsgi |
39 | 39 | |
40 | | Alias /media/ "/usr/lib/python2.5/site-packages/django/contrib/admin/media/" |
41 | | <Directory "/usr/lib/python2.5/site-packages/django/contrib/admin/media/"> |
| 40 | Alias /media/ "/usr/lib/python2.6/site-packages/django/contrib/admin/media/" |
| 41 | <Directory "/usr/lib/python2.6/site-packages/django/contrib/admin/media/"> |
42 | 42 | Order allow,deny |
43 | 43 | Options Indexes |
44 | 44 | Allow from all |
… |
… |
Example::
|
77 | 77 | PythonPath "['/var/www/apps'] + sys.path" |
78 | 78 | </Location> |
79 | 79 | |
80 | | Alias /media/ "/usr/lib/python2.5/site-packages/django/contrib/admin/media/" |
| 80 | Alias /media/ "/usr/lib/python2.6/site-packages/django/contrib/admin/media/" |
81 | 81 | <Location "/media"> |
82 | 82 | SetHandler None |
83 | 83 | </Location> |
diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt
index f0b485f..59a0c36 100644
a
|
b
|
SQLite 3.3.6 was released in April 2006, so most current binary distributions
|
461 | 461 | for different platforms include newer version of SQLite usable from Python |
462 | 462 | through either the ``pysqlite2`` or the ``sqlite3`` modules. |
463 | 463 | |
464 | | However, some platform/Python version combinations include older versions of |
465 | | SQLite (e.g. the official binary distribution of Python 2.5 for Windows, 2.5.4 |
466 | | as of this writing, includes SQLite 3.3.4). There are (as of Django 1.1) even |
467 | | some tests in the Django test suite that will fail when run under this setup. |
468 | | |
469 | | As described :ref:`below<using-newer-versions-of-pysqlite>`, this can be solved |
470 | | by downloading and installing a newer version of ``pysqlite2`` |
471 | | (``pysqlite-2.x.x.win32-py2.5.exe`` in the described case) that includes and |
472 | | uses a newer version of SQLite. Python 2.6 for Windows ships with a version of |
473 | | SQLite that is not affected by these issues. |
474 | | |
475 | 464 | Version 3.5.9 |
476 | 465 | ------------- |
477 | 466 | |
diff --git a/docs/releases/1.5.txt b/docs/releases/1.5.txt
index c8887c2..84459f9 100644
a
|
b
|
Backwards incompatible changes in 1.5
|
39 | 39 | Features deprecated in 1.5 |
40 | 40 | ========================== |
41 | 41 | |
| 42 | itercompat.product |
| 43 | ~~~~~~~~~~~~~~~~~~ |
| 44 | |
| 45 | The :func:`~django.utils.itercompat.product` function has been deprecated. Use |
| 46 | the builtin `itertools.product` instead. |
diff --git a/docs/topics/db/transactions.txt b/docs/topics/db/transactions.txt
index 0f0b52a..589ebc7 100644
a
|
b
|
These functions, described in detail below, can be used in two different ways:
|
93 | 93 | # this code executes inside a transaction |
94 | 94 | # ... |
95 | 95 | |
96 | | Both techniques work with all supported version of Python. However, in Python |
97 | | 2.5, you must add ``from __future__ import with_statement`` at the beginning |
98 | | of your module if you are using the ``with`` statement. |
| 96 | Both techniques work with all supported version of Python. |
99 | 97 | |
100 | 98 | .. _decorator: http://docs.python.org/glossary.html#term-decorator |
101 | 99 | .. _context manager: http://docs.python.org/glossary.html#term-context-manager |
diff --git a/docs/topics/install.txt b/docs/topics/install.txt
index e91c3e0..728ea05 100644
a
|
b
|
Install Python
|
9 | 9 | |
10 | 10 | Being a Python Web framework, Django requires Python. |
11 | 11 | |
12 | | It works with any Python version from 2.5 to 2.7 (due to backwards |
| 12 | It works with any Python version from 2.6 to 2.7 (due to backwards |
13 | 13 | incompatibilities in Python 3.0, Django does not currently work with |
14 | 14 | Python 3.0; see :doc:`the Django FAQ </faq/install>` for more |
15 | 15 | information on supported Python versions and the 3.0 transition). |
diff --git a/docs/topics/testing.txt b/docs/topics/testing.txt
index 39f0770..ad798de 100644
a
|
b
|
your test suite.
|
1591 | 1591 | |
1592 | 1592 | You can use this as a context manager, like this:: |
1593 | 1593 | |
1594 | | # This is necessary in Python 2.5 to enable the with statement. |
1595 | | # In 2.6 and up, it's not necessary. |
1596 | | from __future__ import with_statement |
1597 | | |
1598 | 1594 | with self.assertTemplateUsed('index.html'): |
1599 | 1595 | render_to_string('index.html') |
1600 | 1596 | with self.assertTemplateUsed(template_name='index.html'): |
… |
… |
your test suite.
|
1656 | 1652 | |
1657 | 1653 | self.assertNumQueries(7, lambda: my_function(using=7)) |
1658 | 1654 | |
1659 | | If you're using Python 2.5 or greater you can also use this as a context |
1660 | | manager:: |
1661 | | |
1662 | | # This is necessary in Python 2.5 to enable the with statement, in 2.6 |
1663 | | # and up it is no longer necessary. |
1664 | | from __future__ import with_statement |
| 1655 | You can also use this as a context manager:: |
1665 | 1656 | |
1666 | 1657 | with self.assertNumQueries(2): |
1667 | 1658 | Person.objects.create(name="Aaron") |
diff --git a/setup.py b/setup.py
index 1f14245..a19f660 100644
a
|
b
|
setup(
|
88 | 88 | 'License :: OSI Approved :: BSD License', |
89 | 89 | 'Operating System :: OS Independent', |
90 | 90 | 'Programming Language :: Python', |
91 | | 'Programming Language :: Python :: 2.5', |
92 | 91 | 'Programming Language :: Python :: 2.6', |
93 | 92 | 'Programming Language :: Python :: 2.7', |
94 | 93 | 'Topic :: Internet :: WWW/HTTP', |
diff --git a/tests/regressiontests/forms/tests/widgets.py b/tests/regressiontests/forms/tests/widgets.py
index ce15b8b..2499b7a 100644
a
|
b
|
class FormsWidgetTestCase(TestCase):
|
25 | 25 | self.assertHTMLEqual(w.render('email', 'some "quoted" & ampersanded value'), u'<input type="text" name="email" value="some "quoted" & ampersanded value" />') |
26 | 26 | self.assertHTMLEqual(w.render('email', 'test@example.com', attrs={'class': 'fun'}), u'<input type="text" name="email" value="test@example.com" class="fun" />') |
27 | 27 | |
28 | | # Note that doctest in Python 2.4 (and maybe 2.5?) doesn't support non-ascii |
29 | | # characters in output, so we're displaying the repr() here. |
30 | 28 | self.assertHTMLEqual(w.render('email', 'ŠĐĆŽćžšđ', attrs={'class': 'fun'}), u'<input type="text" name="email" value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" class="fun" />') |
31 | 29 | |
32 | 30 | # You can also pass 'attrs' to the constructor: |