Opened 7 years ago

Closed 4 years ago

#7187 closed (wontfix)

Improved settings import

Reported by: Andrei <andrei@…> Owned by: nobody
Component: Core (Other) Version: master
Severity: Keywords: django.conf settings import mod_python
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I think it would be useful to try importing settings using mod_pyton.apache also. You could then have an .htaccess file like this


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE settings
PythonDebug On
PythonOption mod_python.importer.path "['~/']"

that will work no matter where you place the project and python will be automaticaly activated without modifying other apache configuration files. Classic method using PythonPath will also work so there is no harm adding this patch.

Attachments (2)

apache_import.patch (893 bytes) - added by Andrei <andrei@…> 7 years ago.
modpython.patch (596 bytes) - added by Andrei <andrei@…> 7 years ago.

Download all attachments as: .zip

Change History (12)

Changed 7 years ago by Andrei <andrei@…>

comment:1 Changed 7 years ago by oyvind

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

Handler specific code should not go in core of django.

comment:2 Changed 7 years ago by Andrei <andrei@…>

  • Resolution invalid deleted
  • Status changed from closed to reopened

Yes, you are right, but django.core.handlers.modpython could be patched to append the path to sys.path with the attached patch

Changed 7 years ago by Andrei <andrei@…>

comment:3 Changed 7 years ago by oyvind

  • Resolution set to wontfix
  • Status changed from reopened to closed

Still not sure it is a good idea since it will make this handler work differently than the other handlers.

comment:4 Changed 7 years ago by Andrei <andrei@…>

  • Resolution wontfix deleted
  • Status changed from closed to reopened

I think all handlers could be modified to auto add project directory to sys.path. If you use django internal webserver you don't need to set any path so they are already working differently. Unless there are other problems I don't see why this feature shouldn't be added.

comment:5 Changed 7 years ago by Vali <vali.lungu@…>

I guess Andrei came up with a good idea. In my opinion, there are lots of people using Django + mod_python and quite some are beginners like myself. Having a whole bunch of things to configure before creating a truly versatile, modular Apache+mod_python+Django project ready to be deployed is very cumbersome, especially for someone without years and years of experience.

So, I think that the less you have to configure when setting up your Django projects - the more Django will become appreciated and used by a wider range of developers.

comment:6 Changed 7 years ago by anonymous

I think this must be taken to django-developers, not for me to decide.

But it has to be done for all handlers then.

I personally would not prefer my handler messing with pythonpath.

comment:7 Changed 7 years ago by Andrei <andrei@…>

Sure thing django developers should decide this, but the thing is I can't think of a situation in which I wouldn't need to change the pythonpath and my project still would work. You need to have the applications in the path in order for import to work and why shouldn't that be done automatically?

Any django developer reading this ? :D

comment:9 Changed 7 years ago by serialx

  • Needs documentation set
  • Triage Stage changed from Unreviewed to Design decision needed

comment:10 Changed 4 years ago by lrekucki

  • Keywords mod_python added
  • Resolution set to wontfix
  • Status changed from reopened to closed

mod_python is deprecated, so closing this permanently as won't fix.

Note: See TracTickets for help on using tickets.
Back to Top