[python-sybase] Working on the next release
Dave Cole
djc at object-craft.com.au
19 Apr 2002 00:10:38 +1000
>>>>> "Dave" == Dave Cole <djc@object-craft.com.au> writes:
Dave> Now all I have to do is implement cs_config() in the extension
Dave> module and convert Sybase.py module to used callback error
Dave> handling.
Slow but steady progress...
I have implemented the cs_config() method for CS_CONTEXT objects. I
then realised that a whole class of errors were never reaching the
outside (Python) world due to my use of an internal CS_CONTEXT for
doing numeric conversions (among other things). I decided to fix this
up by placing the creation of the internal CS_CONTEXT under the
control of Python code.
The following is a test program which shows the new features.
- - bugger.py - - - - - - - - - - - - - - - - - - - - - - - - - - -
from sybasect import *
def cslib_cb(ctx, msg):
print 'cslib_cb:'
print ' severity ', msg.severity
print ' msgnumber', msg.msgnumber
print ' msgstring', msg.msgstring
print ' osnumber ', msg.osnumber
print ' osstring ', msg.osstring
print ' status ', msg.status
print ' sqlstate ', msg.sqlstate
raise ValueError('bugger!')
status, ctx = cs_ctx_alloc(CS_VERSION_110)
set_global_ctx(ctx)
ctx.cs_config(CS_SET, CS_MESSAGE_CB, cslib_cb)
numeric('12a')
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
When I run it this is what happens:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cslib_cb:
severity 1
msgnumber 33816856
msgstring cs_convert: cslib user api layer: common library error: The conversion/operation was stopped due to a syntax error in the source field.
osnumber 0
osstring
status 1076857758
sqlstate ZZZZZ
Traceback (most recent call last):
File "bugger.py", line 17, in ?
numeric('12a')
File "bugger.py", line 12, in cslib_cb
raise ValueError('bugger!')
ValueError: bugger!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Now I am finally ready to convert Sybase.py to callback error handling.
- Dave
--
http://www.object-craft.com.au