[redland-dev] Python binding bug
Dave Beckett
dave at dajobe.org
Tue Feb 7 17:16:01 GMT 2006
Anahide Tchertchian wrote:
> Hi,
>
> I've been trying to use the tracker, but I keep on running into an error
> "APPLICATION ERROR #1303 Invalid value for field" when submitting, so
> I'm posting here.
Wierd. I tried submitting a redland bindings test bug, filled in the
only required field (Binding Language) with python and it worked.
> Experienced using version 1.0.2.1.
>
> RedlandError raised is not always a Python class
>
> Some errors coming from Redland are not raised as RedlandError instances
> from the binding, making it impossible to catch them in Python code.
>
> This has been experienced, for instance, creating a mysql storage
> without using the "new='yes'" option whereas tables do not exist. Code
> showing the problem follows.
>
>>>> import RDF
>>>> options =
> "host='localhost',port=3306,user='test',password='test',database='test_redland'"
>
>>>> try:
> ... storage = RDF.Storage(storage_name="mysql", name='test_redland',
> options_string=options)
> ... except RDF.RedlandError:
> ... print "error"
> ...
> Traceback (most recent call last):
> File "<stdin>", line 2, in ?
> File "/usr/lib/python2.4/site-packages/RDF.py", line 1482, in __init__
> args['storage_name'], args['name'], args['options_string'])
> RDF.RedlandError: MySQL select from Models table failed: Table
> 'test_redland.Models' doesn't exist
>>>> try:
> ... storage = RDF.Storage(storage_name="mysql", name='test_redland',
> options_string=options)
> ... except Exception, err:
> ... print "error"
> ...
> error
>>>> isinstance(err, RDF.RedlandError)
> False
>>>> err.__class__
> <class RDF.RedlandError at 0xb7d5ca7c>
>>>> RDF.RedlandError('test').__class__
> <class RDF.RedlandError at 0xb7d5c98c>
Yeah, I've seen that but I don't understand python well enough to know
why it doesn't work. The returned RDF.RedlandError is generated in C
and is a different 'module' from the one defined in RDF.py. So I think
that's why the classes are different even if the names are the same.
Maybe.
module = Py_InitModule("Redland_python", librdf_python_methods);
...
PyRedland_Error = PyErr_NewException("RDF.RedlandError",
PyExc_RuntimeError, NULL);
There are a few fixes/changes in RDF.py in CVS but not in this area.
Dave
More information about the redland-dev
mailing list