New issue 65 by car...@barrobes.com: Incorrect type for IntegrityError
after upgrading while testing with django-1.2 and django-jython hg
http://code.google.com/p/django-jython/issues/detail?id=65
The issue was detected with django-jython 1.3.0b1, jython 2.5.2 and django
1.2, on Ubuntu.
One test in one of my apps which previously passed (django and doj
1.1.1, jython 2.5.1 or 2.5.2rc2) was failing due to an IntegrityError
not being caught. My code looks like:
from django.db import IntegrityError
...
try:
inst.save()
return inst
except IntegrityError:
return rc.DUPLICATE_ENTRY
For debugging purposes I changed the except clause and checked the
type of the exception being thrown and it turns out to be
zxJDBC.IntegrityError instead of django.db.IntegrityError. Django
doesn't seem to recognize that IntegrityError and is not able to wrap
it in its own IntegrityError class.
I'm using the mysql backend, my settings file says:
DATABASES = {
'default': {
'ENGINE': 'doj.backends.zxjdbc.mysql',
etc...
}
}
Any ideas? Is this a bug in the doj backend(s)?
--- WORKAROUND ---
As a workaround I had to use an additional import:
from com.ziclix.python.sql.zxJDBC import IntegrityError as
zxIntegrityError
And modify the try to look like:
try:
inst.save()
return inst
except (IntegrityError, zxIntegrityError):
return rc.DUPLICATE_ENTRY
Comment #1 on issue 65 by juneau001: Incorrect type for IntegrityError
after upgrading while testing with django-1.2 and django-jython hg
http://code.google.com/p/django-jython/issues/detail?id=65
I will look into this issue...not sure if it is specific to DoJ without
investigating further.
Thanks
Comment #2 on issue 65 by juneau001: Incorrect type for IntegrityError
after upgrading while testing with django-1.2 and django-jython hg
http://code.google.com/p/django-jython/issues/detail?id=65
To clarify: Did you make the changes described in WORKAROUND in your
Django project code, or within the zxJDBC code base? If you made them
within your Django-specific code, then I do not believe that this is an
issue as Django-Jython uses zxJDBC rather than django.db code.