Handling database errors in ZSQL
by
antonh
—
last modified
07-Sep-06 11:48 AM
When you don't like the error messages you're getting in Zope, and you want to use a python try..except approach to insert/delete/update, you are faced with a number of options...
Apparently, through-the-web python scripts (as opposed to filesystem products or external methods) can only import a subset of the available modules - a security feature to prevent malicious code.
There are some ways around that limitation:
- Write a custom product which allows a python script to import DCOracle2.DatabaseError - see http://mail.zope.org/pipermail/zope/2002-January/106816.html for an idea of what needs to go in it.
- Use an External Method instead of a Script (Python). To do that you need to put the contents of the script into /home/zope/Extensions, and wrap it in a function. Have a look at the files already in the Extensions folder for an idea. Also, have a look at the following page which has an example of an external method for writing to a DB2 database:
http://www-106.ibm.com/developerworks/ibm/library/i-db2zope/ (about 1/3 of the way down the page).
- use acquisition to your advantage - copy standard_error_message to the GRS folder and customise it to look the way you want it to.