[mod_python] Problems w/ mod python

Joseph Bernhardt joe at incomps.com
Thu Apr 17 16:13:45 EDT 2008


1) How do I import a file in the same folder as the script which is
importing? This does not work:

 

 

Is this directory in your module path?  sys.path

 

 

2) I have the following code:
 
    try:
      cursor.execute(sql)
      print '¡Exito en introducir!<br />'
      print '<i>Esta página va a regresar a la página principal del carrito
de compras en 10 segundos.</i>'
    except IntegrityError:
      print 'Lo siento, pero el ID que entraste está usado actualmente por
otra entrada. Favor de dar para atráz y escojer otro número.'
    except OperationalError:
      print 'Lo siento, pero has añadido un carácter extraño a un número (o
en "ID", "precio", "recámaras" o "baños". Favor de dar para atráz y escojer
otro número.'
    except:
      print 'Lo siento, pero hay un error. Favor de dar para atráz y
averiguar donde está el error, y reintentar.'

When I enter and ID that is not a number, it should trigger the
IntegrityError. Instead, I get this in the error log:
 
[Thu Apr 17 12:06:37 2008] [error] [client 190.166.0.245] PythonHandler
mod_python.cgihandler: NameError: global name 'IntegrityError' is not
defined, referer: http://livestocksling.com/bre/iud.py 

When I enter a non-digit in a float, I should get an OperationalError.
Instead, I get more garbage:
 
[Thu Apr 17 12:10:38 2008] [error] [client 190.166.0.245] PythonHandler
mod_python.cgihandler: NameError: global name 'OperationalError' is not
defined, referer: http://livestocksling.com/bre/iud.py 

What do?

 

These exceptions are probably defined in your sql module.  Since I don’t
know which one that is, here is an example:

 

import MySQLdb

 

try:

              cursor.execute(sql)

except MySQLdb.IntegrityError:

              print ‘oh shit!’

except MySQLdb.OperationalError:

              print ‘holy hell!’

except:

              print ‘too bad
’

 

The errors that you are receiving are not ‘garbage’.  They are telling you
exactly what is happening.  

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20080417/9626a49a/attachment.html


More information about the Mod_python mailing list