| | 213 | |
|---|
| | 214 | Using eggs with mod_python |
|---|
| | 215 | ========================== |
|---|
| | 216 | |
|---|
| | 217 | If you installed Django from a Python egg_ or are using eggs in your Django |
|---|
| | 218 | project, some extra configuration is required. Create an extra file in your |
|---|
| | 219 | project (or somewhere else) that contains something like the following:: |
|---|
| | 220 | |
|---|
| | 221 | import os |
|---|
| | 222 | os.environ['PYTHON_EGG_CACHE'] = '/some/directory' |
|---|
| | 223 | |
|---|
| | 224 | Here, ``/some/directory`` is a directory that the Apache webserver process can |
|---|
| | 225 | write to. It will be used as the location for any unpacking of code the eggs |
|---|
| | 226 | need to do. |
|---|
| | 227 | |
|---|
| | 228 | Then you have to tell mod_python to import this file before doing anything |
|---|
| | 229 | else. This is done using the PythonImport_ directive to mod_python. You need |
|---|
| | 230 | to ensure that you have specified the ``PythonInterpreter`` directive to |
|---|
| | 231 | mod_python as described above__ (you need to do this even if you aren't |
|---|
| | 232 | serving multiple installations in this case). Then add the ``PythonImport`` |
|---|
| | 233 | line inside the ``Location`` or ``VirtualHost`` section. For example:: |
|---|
| | 234 | |
|---|
| | 235 | PythonInterpreter my_django |
|---|
| | 236 | PythonImport /path/to/my/project/file.py my_django |
|---|
| | 237 | |
|---|
| | 238 | Note that you can use an absolute path here (or a normal dotted import path), |
|---|
| | 239 | as described in the `mod_python manual`_. We use an absolute path in the |
|---|
| | 240 | above example because if any Python path modifications are required to access |
|---|
| | 241 | your project, they will not have been done at the time the ``PythonImport`` |
|---|
| | 242 | line is processed. |
|---|
| | 243 | |
|---|
| | 244 | .. _Egg: http://peak.telecommunity.com/DevCenter/PythonEggs |
|---|
| | 245 | .. _PythonImport: http://www.modpython.org/live/current/doc-html/dir-other-pimp.html |
|---|
| | 246 | .. _mod_python manual: PythonImport_ |
|---|
| | 247 | __ `Multiple Django installations on the same Apache`_ |
|---|