quetz-mod_python-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick <n...@dd.revealed.net>
Subject Re: Solving the import problem
Date Wed, 08 Jun 2005 22:26:00 GMT
Yeah I totally agree that something needs to be done there.  It's a good 
utility to have in the mod_python toolbox, and there is a definite need. 
I've looked at Graham's code for caching modules, and it does a good job. 
If something like that could be included in mod_python, probably in util.py, 
that would definitely be an asset.

But definitely EOL the apache.import_module, it just doesn't work well.

Nick

Nicolas Lehuen wrote:
> Nick, what do you think about apache.import_module, as it is now
> and/or as I've described  before ?
> 
> Let's forget about the import hook, let's say import is for standard
> modules only. What do you think about providing our users a way to
> dynamically import some modules without polluting sys.modules
> (remember that shared hosting exists) ?
> 
> Regards,
> Nicolas
> 
> 2005/6/9, Nick <nick@dd.revealed.net>:
> 
>>Graham Dumpleton wrote:
>>
>>>On 09/06/2005, at 12:29 AM, Nick wrote:
>>>
>>>
>>>>but I just want to be clear that I don't think mod_python should
>>>>install any import hooks.  That would probably be annoying to seasoned
>>>>Python programmers, and really a pain in the butt for me specifically.
>>>
>>>Curious to know why you think this would be annoying to seasoned Python
>>>programmers and a pain in the butt to yourself.
>>
>>As I mentioned before, as a programmer I would want mod_python to be an API
>>for apache in Python, with no special alteration of how Python works as
>>advertised in the Python documentation.  Installing import hooks bypasses
>>the Python import functionality as it's documented, and in my opinion is not
>>necessary to use mod_python as an API for apache.
>>
>>While it may be convenient for some people to have an import hook that will
>>automagically reload a module when it changes on disk, that's *not* how
>>Python works, and would be unexpected behaviour for a Python programmer.
>>That's like saying that since most people want to parse the input stream as
>>form data, let's automatically parse it and put it into req.form.  But
>>mod_python doesn't do that.  You have to use utils.FieldStorage.
>>
>>For my own applications I take advantage of Python's internal import routine
>>because it is in C and therefore much faster than any pure Python
>>implementation (try benchmarking an import hook in ihooks and you'll see how
>>slow it is).  I want to inspect sys.modules, and that's where I expect
>>imports to go.  I don't want to bypass an import mechanism that works
>>differently just to get back to Python's; that's counter-intuitive.  Plus,
>>it'll make reuse a pain, because I'll have to write modules with special
>>checks to see if I'm in mod_python or do something else when not.
>>
>>I just don't think default import hooks are necessary to make mod_python
>>generally useful to people.  I can certainly understand people's needs for
>>something more flexible than Python's stock importer when writing
>>applications, and there's always an option to add a module to mod_python
>>that can let people do exactly that.  I just don't want it out of the box.
>>
>>Nick
>>


Mime
View raw message