Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #18029 -- Removed mod_python as of deprecation process. Thanks …

…Aymeric Augustin for the review.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17835 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit a1ffb021072026ad58546609cd2c34f737fd26cc 1 parent 23d3459
Claude Paroz authored March 31, 2012
8  django/core/cache/__init__.py
@@ -14,6 +14,8 @@
14 14
 
15 15
 See docs/topics/cache.txt for information on the public API.
16 16
 """
  17
+from urlparse import parse_qsl
  18
+
17 19
 from django.conf import settings
18 20
 from django.core import signals
19 21
 from django.core.cache.backends.base import (
@@ -21,12 +23,6 @@
21 23
 from django.core.exceptions import ImproperlyConfigured
22 24
 from django.utils import importlib
23 25
 
24  
-try:
25  
-    # The mod_python version is more efficient, so try importing it first.
26  
-    from mod_python.util import parse_qsl
27  
-except ImportError:
28  
-    from urlparse import parse_qsl
29  
-
30 26
 __all__ = [
31 27
     'get_cache', 'cache', 'DEFAULT_CACHE_ALIAS'
32 28
 ]
9  django/http/__init__.py
@@ -9,16 +9,11 @@
9 9
 
10 10
 from pprint import pformat
11 11
 from urllib import urlencode, quote
12  
-from urlparse import urljoin
  12
+from urlparse import urljoin, parse_qsl
13 13
 try:
14 14
     from cStringIO import StringIO
15 15
 except ImportError:
16 16
     from StringIO import StringIO
17  
-try:
18  
-    # The mod_python version is more efficient, so try importing it first.
19  
-    from mod_python.util import parse_qsl
20  
-except ImportError:
21  
-    from urlparse import parse_qsl
22 17
 
23 18
 import Cookie
24 19
 # Some versions of Python 2.7 and later won't need this encoding bug fix:
@@ -348,7 +343,7 @@ def _load_post_and_files(self):
348 343
     ## File-like and iterator interface.
349 344
     ##
350 345
     ## Expects self._stream to be set to an appropriate source of bytes by
351  
-    ## a corresponding request subclass (WSGIRequest or ModPythonRequest).
  346
+    ## a corresponding request subclass (e.g. WSGIRequest).
352 347
     ## Also when request data has already been read by request.POST or
353 348
     ## request.body, self._stream points to a StringIO instance
354 349
     ## containing that data.
9  docs/faq/usage.txt
@@ -13,15 +13,6 @@ Make sure that:
13 13
 
14 14
 * The module doesn't contain syntax errors (of course).
15 15
 
16  
-* If you're using mod_python but *not* using Django's request handler,
17  
-  you'll need to work around a mod_python bug related to the use of
18  
-  ``SetEnv``; before you import anything from Django you'll need to do
19  
-  the following::
20  
-
21  
-        os.environ.update(req.subprocess_env)
22  
-
23  
-  (where ``req`` is the mod_python request object).
24  
-
25 16
 I can't stand your template language. Do I have to use it?
26 17
 ----------------------------------------------------------
27 18
 
110  docs/howto/apache-auth.txt
@@ -2,17 +2,10 @@
2 2
 Authenticating against Django's user database from Apache
3 3
 =========================================================
4 4
 
5  
-.. warning::
6  
-
7  
-    Support for mod_python has been deprecated within Django. At that
8  
-    time, this method of authentication will no longer be provided by
9  
-    Django. The community is welcome to offer its own alternate
10  
-    solutions using WSGI middleware or other approaches.
11  
-
12 5
 Since keeping multiple authentication databases in sync is a common problem when
13 6
 dealing with Apache, you can configuring Apache to authenticate against Django's
14  
-:doc:`authentication system </topics/auth>` directly. For example, you
15  
-could:
  7
+:doc:`authentication system </topics/auth>` directly. This requires Apache
  8
+version >= 2.2 and mod_wsgi >= 2.0. For example, you could:
16 9
 
17 10
 * Serve static/media files directly from Apache only to authenticated users.
18 11
 
@@ -22,106 +15,31 @@ could:
22 15
 * Allow certain users to connect to a WebDAV share created with mod_dav_.
23 16
 
24 17
 .. _Subversion: http://subversion.tigris.org/
25  
-.. _mod_dav: http://httpd.apache.org/docs/2.0/mod/mod_dav.html
  18
+.. _mod_dav: http://httpd.apache.org/docs/2.2/mod/mod_dav.html
26 19
 
27 20
 Configuring Apache
28 21
 ==================
29 22
 
30 23
 To check against Django's authorization database from a Apache configuration
31  
-file, you'll need to use mod_python's ``PythonAuthenHandler`` directive along
32  
-with the standard ``Auth*`` and ``Require`` directives:
  24
+file, you'll need to set 'wsgi' as the value of ``AuthBasicProvider`` or
  25
+``AuthDigestProvider`` directive and then use the ``WSGIAuthUserScript``
  26
+directive to set the path to your authentification script:
33 27
 
34 28
 .. code-block:: apache
35 29
 
36 30
     <Location /example/>
37 31
         AuthType Basic
38 32
         AuthName "example.com"
  33
+        AuthBasicProvider wsgi
  34
+        WSGIAuthUserScript /usr/local/wsgi/scripts/auth.wsgi
39 35
         Require valid-user
40  
-
41  
-        SetEnv DJANGO_SETTINGS_MODULE mysite.settings
42  
-        PythonAuthenHandler django.contrib.auth.handlers.modpython
43 36
     </Location>
44 37
 
45  
-.. admonition:: Using the authentication handler with Apache 2.2
46  
-
47  
-    If you're using Apache 2.2, you'll need to take a couple extra steps.
48  
-
49  
-    You'll need to ensure that ``mod_auth_basic`` and ``mod_authz_user``
50  
-    are loaded. These might be compiled statically into Apache, or you might
51  
-    need to use ``LoadModule`` to load them dynamically (as shown in the
52  
-    example at the bottom of this note).
53  
-
54  
-    You'll also need to insert configuration directives that prevent Apache
55  
-    from trying to use other authentication modules, as well as specifying
56  
-    the ``AuthUserFile`` directive and pointing it to ``/dev/null``. Depending
57  
-    on which other authentication modules you have loaded, you might need one
58  
-    or more of the following directives:
59  
-
60  
-    .. code-block:: apache
61  
-
62  
-        AuthBasicAuthoritative Off
63  
-        AuthDefaultAuthoritative Off
64  
-        AuthzLDAPAuthoritative Off
65  
-        AuthzDBMAuthoritative Off
66  
-        AuthzDefaultAuthoritative Off
67  
-        AuthzGroupFileAuthoritative Off
68  
-        AuthzOwnerAuthoritative Off
69  
-        AuthzUserAuthoritative Off
70  
-
71  
-    A complete configuration, with differences between Apache 2.0 and
72  
-    Apache 2.2 marked in bold, would look something like:
73  
-
74  
-    .. parsed-literal::
75  
-
76  
-        **LoadModule auth_basic_module modules/mod_auth_basic.so**
77  
-        **LoadModule authz_user_module modules/mod_authz_user.so**
78  
-
79  
-        ...
80  
-
81  
-        <Location /example/>
82  
-            AuthType Basic
83  
-            AuthName "example.com"
84  
-            **AuthUserFile /dev/null**
85  
-            **AuthBasicAuthoritative Off**
86  
-            Require valid-user
87  
-
88  
-            SetEnv DJANGO_SETTINGS_MODULE mysite.settings
89  
-            PythonAuthenHandler django.contrib.auth.handlers.modpython
90  
-        </Location>
91  
-
92  
-By default, the authentication handler will limit access to the ``/example/``
93  
-location to users marked as staff members.  You can use a set of
94  
-``PythonOption`` directives to modify this behavior:
95  
-
96  
-================================  =========================================
97  
-``PythonOption``                  Explanation
98  
-================================  =========================================
99  
-``DjangoRequireStaffStatus``      If set to ``on`` only "staff" users (i.e.
100  
-                                  those with the ``is_staff`` flag set)
101  
-                                  will be allowed.
102  
-
103  
-                                  Defaults to ``on``.
104  
-
105  
-``DjangoRequireSuperuserStatus``  If set to ``on`` only superusers (i.e.
106  
-                                  those with the ``is_superuser`` flag set)
107  
-                                  will be allowed.
108  
-
109  
-                                  Defaults to ``off``.
110  
-
111  
-``DjangoPermissionName``          The name of a permission to require for
112  
-                                  access. See :ref:`custom permissions
113  
-                                  <custom-permissions>` for more
114  
-                                  information.
115  
-
116  
-                                  By default no specific permission will be
117  
-                                  required.
118  
-================================  =========================================
  38
+Your auth.wsgi script will have to implement either a
  39
+``check_password(environ, user, password)`` function (for ``AuthBasicProvider``)
  40
+or a ``get_realm_hash(environ, user, realm)`` function (for ``AuthDigestProvider``).
119 41
 
120  
-Note that sometimes ``SetEnv`` doesn't play well in this mod_python
121  
-configuration, for reasons unknown. If you're having problems getting
122  
-mod_python to recognize your ``DJANGO_SETTINGS_MODULE``, you can set it using
123  
-``PythonOption`` instead of ``SetEnv``. Therefore, these two Apache directives
124  
-are equivalent::
  42
+See the `mod_wsgi documentation`_ for more details about the implementation
  43
+of such a solution.
125 44
 
126  
-    SetEnv DJANGO_SETTINGS_MODULE mysite.settings
127  
-    PythonOption DJANGO_SETTINGS_MODULE mysite.settings
  45
+.. _mod_wsgi documentation: http://code.google.com/p/modwsgi/wiki/AccessControlMechanisms#Apache_Authentication_Provider
3  docs/howto/deployment/index.txt
@@ -11,7 +11,6 @@ ways to easily deploy Django:
11 11
 
12 12
    wsgi/index
13 13
    fastcgi
14  
-   mod_python (deprecated) <modpython>
15 14
 
16 15
 If you're new to deploying Django and/or Python, we'd recommend you try
17 16
 :doc:`mod_wsgi </howto/deployment/wsgi/modwsgi>` first. In most cases it'll be
@@ -22,6 +21,6 @@ the easiest, fastest, and most stable deployment choice.
22 21
     * `Chapter 12 of the Django Book (second edition)`_ discusses deployment
23 22
       and especially scaling in more detail. However, note that this edition
24 23
       was written against Django version 1.1 and has not been updated since
25  
-      :doc:`mod_python </howto/deployment/modpython>` was deprecated.
  24
+      `mod_python` was first deprecated, then completely removed in Django 1.5.
26 25
 
27 26
 .. _chapter 12 of the django book (second edition): http://djangobook.com/en/2.0/chapter12/
21  docs/howto/deployment/wsgi/modwsgi.txt
@@ -176,3 +176,24 @@ other approaches:
176 176
 
177 177
 3. Copy the admin static files so that they live within your Apache
178 178
    document root.
  179
+
  180
+If you get a UnicodeEncodeError
  181
+===============================
  182
+
  183
+If you're taking advantage of the internationalization features of Django (see
  184
+:doc:`/topics/i18n/index`) and you intend to allow users to upload files, you must
  185
+ensure that the environment used to start Apache is configured to accept
  186
+non-ASCII file names. If your environment is not correctly configured, you
  187
+will trigger ``UnicodeEncodeError`` exceptions when calling functions like
  188
+``os.path()`` on filenames that contain non-ASCII characters.
  189
+
  190
+To avoid these problems, the environment used to start Apache should contain
  191
+settings analogous to the following::
  192
+
  193
+    export LANG='en_US.UTF-8'
  194
+    export LC_ALL='en_US.UTF-8'
  195
+
  196
+Consult the documentation for your operating system for the appropriate syntax
  197
+and location to put these configuration items; ``/etc/apache2/envvars`` is a
  198
+common location on Unix platforms. Once you have added these statements
  199
+to your environment, restart Apache.
1  docs/index.txt
@@ -156,7 +156,6 @@ The development process
156 156
   :doc:`Overview <howto/deployment/index>` |
157 157
   :doc:`WSGI servers <howto/deployment/wsgi/index>` |
158 158
   :doc:`FastCGI/SCGI/AJP <howto/deployment/fastcgi>` |
159  
-  :doc:`Apache/mod_python (deprecated) <howto/deployment/modpython>` |
160 159
   :doc:`Apache authentication <howto/apache-auth>` |
161 160
   :doc:`Handling static files <howto/static-files>` |
162 161
   :doc:`Tracking code errors by email <howto/error-reporting>`
44  docs/ref/contrib/gis/deployment.txt
@@ -13,11 +13,9 @@ Deploying GeoDjango
13 13
 Apache
14 14
 ======
15 15
 In this section there are some example ``VirtualHost`` directives for
16  
-when deploying using either ``mod_python`` or ``mod_wsgi``.  At this
17  
-time, we recommend ``mod_wsgi``, as it is now officially recommended
18  
-way to deploy Django applications with Apache.  Moreover, if
19  
-``mod_python`` is used, then a prefork version of Apache must also be
20  
-used.  As long as ``mod_wsgi`` is configured correctly, it does not
  16
+when deploying using ``mod_wsgi``, which is now officially the recommended
  17
+way to deploy Django applications with Apache.
  18
+As long as ``mod_wsgi`` is configured correctly, it does not
21 19
 matter whether the version of Apache is prefork or worker.
22 20
 
23 21
 .. note::
@@ -56,42 +54,6 @@ Example::
56 54
 For more information, please consult Django's
57 55
 :doc:`mod_wsgi documentation </howto/deployment/wsgi/modwsgi>`.
58 56
 
59  
-``mod_python``
60  
---------------
61  
-
62  
-.. warning::
63  
-    Support for mod_python will be deprecated in a future release of Django. If
64  
-    you are configuring a new deployment, you are strongly encouraged to
65  
-    consider using :doc:`mod_wsgi </howto/deployment/wsgi/modwsgi>` or any of
66  
-    the other :doc:`supported servers </howto/deployment/index>`.
67  
-
68  
-Example::
69  
-
70  
-    <VirtualHost *:80>
71  
-
72  
-      <Location "/">
73  
-        SetHandler mod_python
74  
-        PythonHandler django.core.handlers.modpython
75  
-        SetEnv DJANGO_SETTINGS_MODULE world.settings
76  
-        PythonDebug On
77  
-        PythonPath "['/var/www/apps'] + sys.path"
78  
-      </Location>
79  
-
80  
-      Alias /media/ "/usr/lib/python2.6/site-packages/django/contrib/admin/media/"
81  
-      <Location "/media">
82  
-        SetHandler None
83  
-      </Location>
84  
-
85  
-    </VirtualHost>
86  
-
87  
-.. warning::
88  
-
89  
-   When using ``mod_python`` you *must* be using a prefork version of Apache, or
90  
-   else your GeoDjango application may crash Apache.
91  
-
92  
-For more information, please consult Django's
93  
-:doc:`mod_python documentation </howto/deployment/modpython>`.
94  
-
95 57
 Lighttpd
96 58
 ========
97 59
 
6  docs/ref/request-response.txt
@@ -56,15 +56,13 @@ All attributes except ``session`` should be considered read-only.
56 56
 .. attribute:: HttpRequest.path_info
57 57
 
58 58
     Under some Web server configurations, the portion of the URL after the host
59  
-    name is split up into a script prefix portion and a path info portion
60  
-    (this happens, for example, when using the ``django.root`` option
61  
-    with the :doc:`modpython handler from Apache </howto/deployment/modpython>`).
  59
+    name is split up into a script prefix portion and a path info portion.
62 60
     The ``path_info`` attribute always contains the path info portion of the
63 61
     path, no matter what Web server is being used. Using this instead of
64 62
     attr:`~HttpRequest.path` can make your code much easier to move between test
65 63
     and deployment servers.
66 64
 
67  
-    For example, if the ``django.root`` for your application is set to
  65
+    For example, if the ``WSGIScriptAlias`` for your application is set to
68 66
     ``"/minfo"``, then ``path`` might be ``"/minfo/music/bands/the_beatles/"``
69 67
     and ``path_info`` would be ``"/music/bands/the_beatles/"``.
70 68
 
4  docs/topics/http/urls.txt
@@ -1020,6 +1020,4 @@ find the base URL of the Django project within its Web server
1020 1020
 (normally, :func:`~django.core.urlresolvers.reverse` takes care of this for
1021 1021
 you). In that case, you can call ``get_script_prefix()``, which will return the
1022 1022
 script prefix portion of the URL for your Django project. If your Django
1023  
-project is at the root of its Web server, this is always ``"/"``, but it can be
1024  
-changed, for instance  by using ``django.root`` (see :doc:`How to use
1025  
-Django with Apache and mod_python </howto/deployment/modpython>`).
  1023
+project is at the root of its Web server, this is always ``"/"``.
36  tests/regressiontests/requests/tests.py
@@ -4,7 +4,6 @@
4 4
 from StringIO import StringIO
5 5
 
6 6
 from django.conf import settings
7  
-from django.core.handlers.modpython import ModPythonRequest
8 7
 from django.core.handlers.wsgi import WSGIRequest, LimitedStream
9 8
 from django.http import HttpRequest, HttpResponse, parse_cookie, build_request_repr, UnreadablePostError
10 9
 from django.test.utils import get_warnings_state, restore_warnings_state
@@ -54,41 +53,6 @@ def test_wsgirequest_repr(self):
54 53
         self.assertEqual(build_request_repr(request, path_override='/otherpath/', GET_override={u'a': u'b'}, POST_override={u'c': u'd'}, COOKIES_override={u'e': u'f'}, META_override={u'g': u'h'}),
55 54
                          u"<WSGIRequest\npath:/otherpath/,\nGET:{u'a': u'b'},\nPOST:{u'c': u'd'},\nCOOKIES:{u'e': u'f'},\nMETA:{u'g': u'h'}>")
56 55
 
57  
-    def test_modpythonrequest(self):
58  
-        class FakeModPythonRequest(ModPythonRequest):
59  
-           def __init__(self, *args, **kwargs):
60  
-               super(FakeModPythonRequest, self).__init__(*args, **kwargs)
61  
-               self._get = self._post = self._meta = self._cookies = {}
62  
-
63  
-        class Dummy:
64  
-            def get_options(self):
65  
-                return {}
66  
-
67  
-        req = Dummy()
68  
-        req.uri = 'bogus'
69  
-        request = FakeModPythonRequest(req)
70  
-        self.assertEqual(request.path, 'bogus')
71  
-        self.assertEqual(request.GET.keys(), [])
72  
-        self.assertEqual(request.POST.keys(), [])
73  
-        self.assertEqual(request.COOKIES.keys(), [])
74  
-        self.assertEqual(request.META.keys(), [])
75  
-
76  
-    def test_modpythonrequest_repr(self):
77  
-        class Dummy:
78  
-            def get_options(self):
79  
-                return {}
80  
-        req = Dummy()
81  
-        req.uri = '/somepath/'
82  
-        request = ModPythonRequest(req)
83  
-        request._get = {u'get-key': u'get-value'}
84  
-        request._post = {u'post-key': u'post-value'}
85  
-        request._cookies = {u'post-key': u'post-value'}
86  
-        request._meta = {u'post-key': u'post-value'}
87  
-        self.assertEqual(repr(request), u"<ModPythonRequest\npath:/somepath/,\nGET:{u'get-key': u'get-value'},\nPOST:{u'post-key': u'post-value'},\nCOOKIES:{u'post-key': u'post-value'},\nMETA:{u'post-key': u'post-value'}>")
88  
-        self.assertEqual(build_request_repr(request), repr(request))
89  
-        self.assertEqual(build_request_repr(request, path_override='/otherpath/', GET_override={u'a': u'b'}, POST_override={u'c': u'd'}, COOKIES_override={u'e': u'f'}, META_override={u'g': u'h'}),
90  
-                         u"<ModPythonRequest\npath:/otherpath/,\nGET:{u'a': u'b'},\nPOST:{u'c': u'd'},\nCOOKIES:{u'e': u'f'},\nMETA:{u'g': u'h'}>")
91  
-
92 56
     def test_parse_cookie(self):
93 57
         self.assertEqual(parse_cookie('invalid:key=true'), {})
94 58
 

0 notes on commit a1ffb02

Please sign in to comment.
Something went wrong with that request. Please try again.