[mod_python] The new module loader

Graham Dumpleton grahamd at dscpl.com.au
Fri Apr 21 18:57:18 EDT 2006


On 22/04/2006, at 6:35 AM, Dan Eloff wrote:

> Hey Graham,
>
> I'm running into one problem related to taking things out of the
> packages. I've imported PyServer.module_name in many places in my
> modules but of course now PyServer no longer exists and all it's
> modules are in the directory with pyserver.py which contains the
> handler. I changed import PyServer.config to just import config, but
> it doesn't find it.
>
> I'm loathe to use absolute or even relative paths because of how many
> different places I'd have to modify it. Is there some way to globally
> add the handler's directory to the search path?

I gotta run out the door, so no time to answer all questions right now.

Can you clarify when you say "handler directory" whether you mean
the directory that pserver.py is in, or the directory indicated by the
Directory directive where you specified PythonHandler?

Also, are you setting PythonPath directive?

Oh, and give locations of pyserver.py and config.py, along with any path
used with Directory directive so I have context.

In a rush, so take note of comments in:

   http://issues.apache.org/jira/browse/MODPYTHON-154
   http://www.dscpl.com.au/articles/modpython-007.html#setting-of- 
pythonpath

in the mean time.

You may be coming up against preserved behaviour from old
importer that frankly I think should not be kept.

Thanks.

Graham


> On 4/21/06, Dan Eloff <dan.eloff at gmail.com> wrote:
>> Whoops. I was looking over the code for import_module and I  
>> figured it
>> out. path is meant to be a list, duh. Maybe add an
>>
>> assert not path or isinstance(path, list), 'path must be a list of
>> paths to search for the module.'
>>
>> to your code near the top of the function. Otherwise if path is a
>> string, search_path.extend(path) doesn't throw, but it makes a huge
>> search_path of single character locations and fails utterly (and
>> silently)
>>
>> -Dan
>>



More information about the Mod_python mailing list