Paul Culley
2017-06-04 22:44:30 UTC
Gentlemen;
Per https://gramps-project.org/bugs/view.php?id=9541
which discusses various API methods which were added to DBAPI but never
officially made part of the Gramps API, I'm asking for a review of one
particular method which I would like to use to patch a bug.
The has_handle(obj_key, handle) method takes an obj_key (PERSON_KEY, etc.)
and a handle and determines if the db contains the handle, without raising
a HandleError.
This was added to dbapi by Doug Blank a while ago, presumably because he
expected it to be useful.
I've found a spot where I can use it as well; it turns out that when we
decided to raise HandleErrors for invalid handles, we started getting a lot
of these errors from our Gramplets. The Gramplets were originally designed
to deal with 'None' returns from the various db operations, but don't deal
with HandleErrors. Someone put in what I would consider to be a bandaid (a
'try' 'except' clause around our signal 'emit' code, which catches most of
these, but not all.
I'd like to fix up the base Gramplet class which has a get_active method
that returns the active handle, to check if the handle is valid before
passing to the Gramplets, thus not having to fix all of the Gramplets
individually. But to do this, I have to check the handle for the various
object types used by the Gramplets. This can be done pretty easily via the
has_handle method.
I've submitted a PR https://github.com/gramps-project/gramps/pull/412 that
adds the has_handle method to bsddb and patches the bug if anyone cares to
see what this looks like.
Paul Culley
Per https://gramps-project.org/bugs/view.php?id=9541
which discusses various API methods which were added to DBAPI but never
officially made part of the Gramps API, I'm asking for a review of one
particular method which I would like to use to patch a bug.
The has_handle(obj_key, handle) method takes an obj_key (PERSON_KEY, etc.)
and a handle and determines if the db contains the handle, without raising
a HandleError.
This was added to dbapi by Doug Blank a while ago, presumably because he
expected it to be useful.
I've found a spot where I can use it as well; it turns out that when we
decided to raise HandleErrors for invalid handles, we started getting a lot
of these errors from our Gramplets. The Gramplets were originally designed
to deal with 'None' returns from the various db operations, but don't deal
with HandleErrors. Someone put in what I would consider to be a bandaid (a
'try' 'except' clause around our signal 'emit' code, which catches most of
these, but not all.
I'd like to fix up the base Gramplet class which has a get_active method
that returns the active handle, to check if the handle is valid before
passing to the Gramplets, thus not having to fix all of the Gramplets
individually. But to do this, I have to check the handle for the various
object types used by the Gramplets. This can be done pretty easily via the
has_handle method.
I've submitted a PR https://github.com/gramps-project/gramps/pull/412 that
adds the has_handle method to bsddb and patches the bug if anyone cares to
see what this looks like.
Paul Culley