[mod_python] The DOs and DONTs of mod_python

Philippe C. Martin pmartin at snakecard.com
Tue Oct 18 16:58:18 EDT 2005

Hi and thanks again for the previous answer.

Since I just managed to seg fault apache I feel I should explain what my goal 
is with mod_python.

I already have a fairly big library written in python which purpose is to 
discuss with smart cards but also provide "software" enryption capabilites: 
As such, this library uses modules that in turn talk to C code.

The ultimate goal is to have users need to authenticate themselves to the 
servers (on smart card on each side) in order to obtain access to certain 

I must also say that there is a failry large data set that needs to be loaded 
in memory.

The code below shows the line that creates the core dump: it instantiates that 
_large_ object and does a lot in the process.

As I am an application developper more than a web guy, there are perhaps some 
obvious "NO NOs'" I should be aware of that are related to the apache 

Please note that, although I must have bugs, the code I'm calling _seems_ to 
work flawlessly under Linux and Windows.

Thanks and regards,


from mod_python import apache
import os
import sys
if os.name == 'nt':

from SC.pilot.SC_Script_Processor import *

def world(req):
     ls = SC_Script_Processor() #INSTANTIATE A _BIG_ OBJECT ==> *** THIS IS 
     ll = ls.Reader_List() # get the reader list

     #Grab ATR from card - assume first reader
     l_appli_conn = ls.Get_Connection(r1)
     req.write("RETURN CARD ATR= " +  l_appli_conn.Get_Connection_ATR() )


     return apache.OK

More information about the Mod_python mailing list