[mod_python] Problem with mod_python and ZConfig

Ville Silventoinen vsi at ebi.ac.uk
Fri Jun 17 12:37:58 EDT 2005


Hi,

I found some clues from here:

http://www.modpython.org/pipermail/mod_python/2004-May/015569.html

To put it shortly: you need to make sure Python and mod_python are using
the same expat library. Python 2.4 includes with expat-1.95.2, mod_python 
(or is it Apache, I'm not 100% sure) compiles with system expat (1.95.5 in
my Linux OS), which creates the segfault problem.

I have just installed expat-1.95.8 and I'm in the process of recompiling
Python-2.4 and mod_python. In my case I need to install expat and Python
in a non-standard path, which is mounted over NFS on several machines.

I'll write short instructions if I get it working (next week)!

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