[Zope] Newbie: Exception Handling questions
Luis Mariano Luporini
lluporini@yahoo.com.ar
Mon, 17 Mar 2003 03:41:56 -0300
Hi list:
I'm trying to learn more about Zope/Python. I think it's a
really great tool.
Now my situation:
I'm using Zope 2.6.1 w/ Python 2.1.3, z/psycopg 1.1.2 and
Postgres 7.3 on Gentoo Linux.
I have a connection open to the pg server, I can
select/delete/insert/update without problems.
I have now a ZSql method that performs an insert and I have a
Python Script that calls it. I'd like to check if the execution of the
insert operation was succesful and if not, the reason.
Now the questions:
1) I've read about try/except and StandarError.
if I use something like:
try:
some statement
except StandardError, e:
print e
I got a whole string containing the sql executed an a
description of the error. So what is e really? Can I get an error
number, description and more information out of e? If not how can i do it?
2) Trying to specialize the exception treated I changed
StandardError for IntegrityError/DatabaseError but in both cases i got:
*Error Type: NameError*
* Error Value: global name 'DatabaseError/IntegrityError' is not
defined*
Then i added to the script "import psycopg", with the same
results and finally tried "import psycopg.Error" and got
*Error Type: ImportError*
* Error Value: import of "psycopg.Error" is unauthorized
So which way I have to go?
Thanks in advance.
Luis.
*
------------
¡Internet GRATIS es Yahoo! Conexión!
Usuario "yahoo", contraseña "yahoo".
Desde Buenos Aires, 4004-1010.
Otras ciudades: http://conexion.yahoo.com.ar/avanzados.html