[Zope-DB] Catching and using DCOracle2 exceptions in a Script (Python)

Anton Hughes Anton.Hughes@utas.edu.au
Wed, 14 May 2003 10:45:51 +1000


Hi All,

I'm trying to catch and handle an exception when using a ZSQL method to
insert/update/delete data in an Oracle 9i database via a DCOracle2
connection. The following script is a trimmed down version of what I'm
doing:

##### start script #####
request = container.REQUEST

try:
  context.zsql_method( request )
  message = "Method has been invoked"
except StandardError, e:
  message = str(e)

return context.actionResult( message = message, referer =
request.HTTP_REFERER )
##### end script #####

However, what I'd really like to do is to determine whether I have an Oracle
error and return the error number, etc to the user. If I replace
StandardError in the script above with DCOracle2.Database error then I get a
message saying I'm not authorized to use DCOracle2 in this context.


Can anyone point me in the right direction?

Thanks,

Anton Hughes

Data Administrator
Childhood Determinants of Adult Health Project
Menzies Centre for Population Health Research
Private Bag 23, Hobart Tasmania 7001

Email: anton.hughes@utas.edu.au
Web:  http://www.menzies.utas.edu.au/cohort/CDAH.htm
Phone: +61 (0) 3 6226 7761

=+=+++=====+++++++++=================+++++++++++++++++++++++++++++++
If you think education is expensive, try ignorance.
                -- Derek Bok, president of Harvard