Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#2951 closed enhancement (wontfix)

Abstract loader support for module import

Reported by: richard@… Owned by: Adrian Holovaty
Component: Core (Other) Version:
Severity: trivial Keywords: apache, mod_python
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Instead of using import all over the place where importing of modules is required, abstract the import routines so that it can take advantage of module loading code if already in existance. e.g. apache.import_module()

It means tighter integration with apache's mod_python, and also means that it's a little more intelligent when used in such an environment.

Granted it's a teensy weensy little bit more overhead per request, however that should be negated by mod_pythons own module resolution code.

As I understand mod_python at the moment, 'imports' made outside of the apache.import_module() framework do not get reloaded by mod_python.

Change History (5)

comment:1 Changed 11 years ago by Adrian Holovaty

Oooh, I like this idea! Would you be willing to code up a patch?

comment:2 Changed 11 years ago by richard@…

Yeah, sure :)

Currently I could 32 instances of import in stock 0.95

comment:3 Changed 11 years ago by Adrian Holovaty

Resolution: wontfix
Status: newclosed

Well, wait. My preference is always to run Django with mod_python's PythonReload Off directive, which would negate the usefulness of this improvement. This would only benefit people who make changes to their Python modules while Apache is running and expect those changes to be reflected without a server restart. I don't know that it's worth changing the way we import things for such a small benefit...

(Sorry for leading you astray with my previous comment! I'm marking this as wontfix.)

comment:4 Changed 11 years ago by verbosus

I don’t want to waste anyone’s time, but I’m not sure I agree with Adrian here.

I use Django with mod_python PythonReload Off as well on some of my sites, but having this code in would allow for people to run Django in a shared hosting environment without shell access. Granted, that may not be the best deployment option of the world for Django (and may also be considered evil from a security point of view) but it’s still a potentially useful use-case. I, for one, would have a use of it in some other websites I manage.

Richard: how painful would the code changes be compared to what is in Django now? Adrian, if Richard’s changes are not too hairy I would propose to reconsider the wontfix.

comment:5 Changed 11 years ago by Adrian Holovaty

Richard tried to post the following comment but was barred by the spam filter. He e-mailed it to me, and I'm posting it here:

Actually I disagree. For a development environment, having to reload
apache frequently is a pain in the arse and sometimes slows
development. I mean how many times have you made changes to your code,
run your web based unit tests, then discovered apache is using the old

Apache's import_module function can check to see if it should reload
the module if necessary, which can be bound to settings.DEBUG... if
Debug is enabled then it re-loads the module...

It's not that much of a change if the truth be told. The only
complication is that I'd have to emulate the fromlist functionality of
__import__, which might not be a good thing [tm] performance wise. It
onlt means replacing the umpteen __import__(modulename,{},{},[])

Of course, this is only really useful in a mod_python environment.
Unless your running a WSGI interface in mod_python for django, it's a
pointless exercise, however would be beneficial to some users, as
verbosus says, developers and shared hosting developers/users.

I'm happy to write up a patch. As far as I'm concerned, when I'm
actually writing code, I like apache to be running the latest version
of my code, as opposed to what it thinks is the latest version of my
code. But then I'm a hard ass mod_python junkie.

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