[mod_python] Problem with mod_python and ZConfig

Ville Silventoinen vsi at ebi.ac.uk
Tue Jun 21 04:24:25 EDT 2005


Hi,

just to summarize:

I got ZConfig working. In my environment, I cannot use standard
paths, because we have many web servers, which share the same
binaries over NFS. Here's what I did:

1. I compiled expat-1.95.8 to location /path/to/expat.

2. I recompiled Apache 2.0.54 using --with-expat=/path/to/expat
option with configure. I checked with "ldd httpd" that Apache
depends now on right expat shared library.

3. I compiled Python 2.4.1, which contains its own expat-1.95.8.
I didn't modify Modules/Setup.

4. I compiled mod_python 3.1.4.

5. I configured Apache, stopped and started the server.
I tested with a handler that uses ZConfig. It works!

Upgrading the system expat wasn't an option for me (we use the same
Linux image on our web servers, which cannot be changed just like
that), but probably it is the easiest solution if you have just one
or two servers to look after.

I'm quite surprised that this problem is not mentioned in mod_python
documentation. Luckily I found information on this mailing list and
on few pages:

http://uche.ogbuji.net/tech/akara/nodes/2005-03-23/expat
http://www.cheshire3.org/docs/install.html
http://www.modpython.org/pipermail/mod_python/2005-January/017250.html
http://www.modpython.org/pipermail/mod_python/2004-May/015561.html


Cheers,
Ville






On Fri, 17 Jun 2005, dharana wrote:

> I too am having problems related to xml but from another package: 4Suite, 
> which I believe is also based on xml.sax and expat. from Ft.Xml import 
> MarkupWriter works if it's called from cmdline mode but it segfaults if 
> called from mod_python.
>
>
> Ville Silventoinen wrote:
>> Hi,
>> 
>> looks like the problem is with xml.sax and expat. I found other
>> mails about the same problem.
>> 
>> Cheers,
>> Ville
>> 
>> 
>> On Fri, 17 Jun 2005, Ville Silventoinen wrote:
>> 
>>> Hi,
>>> 
>>> I've been looking for something more extensive than ConfigParser
>>> for my configuration files, so I tried ZConfig 2.3. I wrote a small
>>> test module that uses ZConfig, which works ok. When I tried to use
>>> the same module with mod_python, I get a Segmentation fault.
>>> 
>>> Has anyone had similar problems using mod_python with ZConfig 2.x?
>>> 
>>> My test handler looks like this:
>>> 
>>>  from mod_python import apache
>>>  import ZConfig
>>> 
>>>  SCHEMA_FILE = '/homes/vsi/src/spylib/lib/Spy/spyschema.xml'
>>>  CONFIG_FILE = '/homes/vsi/src/spylib/lib/Spy/spy.conf'
>>> 
>>>  def handler(req):
>>>      try:
>>>          req.write("Trying to load configuration...\n");
>>>          schema = ZConfig.loadSchema(SCHEMA_FILE)
>>>          config, handler = ZConfig.loadConfig(schema, CONFIG_FILE)
>>>          req.write("Configuration loaded\n")
>>>      except Exception, e:
>>>          req.write("Failed to load configuration:\n%s" % str(e))
>>> 
>>>      return apache.OK
>>> 
>>> When called, I see "Trying to load configuration..." and then nothing.
>>> In Apache error_log I get:
>>> 
>>> [Fri Jun 17 13:09:31 2005] [notice] mod_python: (Re)importing module 
>>> 'testMPConfig'
>>> [Fri Jun 17 13:09:33 2005] [notice] child pid 26452 exit signal 
>>> Segmentation fault (11)
>>> 
>>> This happens every time I call the handler.
>>> 
>>> My configuration:
>>> 
>>>  LoadModule python_module /ebi/www/main/modules/mod_python.so
>>> 
>>>  <Directory /ebi/www/main/cgi-bin/vsi/test>
>>>    AddHandler mod_python .py
>>>    PythonHandler testMPConfig
>>>    PythonAutoReload On
>>>    PythonDebug On
>>>  </Directory>
>>> 
>>> My environment:
>>> 
>>>  Apache-2.0.54
>>>  Python-2.4
>>>  mod_python-3.1.3
>>>  ZConfig 2.3 (tried 2.2 as well)
>>>  Red Hat Linux release 9 (Shrike) 2.4.20-8rlx4smp
>>> 
>>> Any help would be appreciated. I've tried commenting lines out of the
>>> handler, looks like the problem happens with "loadSchema". I also tried
>>> to use "loadSchemaFile", but it didn't help.
>>> 
>>> On the same note, what is the recommended way to handle configuration
>>> with Python? I'm fairly new to Python. I'd like to have a configuration
>>> that is reloaded automatically when modified, validation rules, sections
>>> and proper values (so that integer strings become ints/longs in the
>>> configuration object, keys with multiple values become lists, etc.)
>>> Is the best way to write a Python module that contains the configuration?
>>> This would skip parsing phase and let mod_python reload the module when
>>> it's been modified.
>>> 
>>> Thanks,
>>> Ville
>>> 
>>> _______________________________________________
>>> Mod_python mailing list
>>> Mod_python at modpython.org
>>> http://mailman.modpython.org/mailman/listinfo/mod_python
>>> 
>> _______________________________________________
>> Mod_python mailing list
>> Mod_python at modpython.org
>> http://mailman.modpython.org/mailman/listinfo/mod_python
>> 
>> 
>> 
>
> -- 
> dharana
>
>


More information about the Mod_python mailing list