Is there a errorless test for "no database loaded"

Is there a test that Gramplets can use to determine if the dummy database (or no database) is loaded?

The default Dashboard layout includes the “Top Surnames” Gramplet. This causes a statusbar warning when no Tree is loaded in Gramps.

I’d like to experiment with adding some state of the database checking to this Gramplet so it gives a more useful response for newbies… AND so it doesn’t pop a statusbar lightbulb icon. (As with most of the conditions that cause an alert on the Statusbar, the reported message doesn’t suggest a resolution for a non-technical user.)

Rather than reporting Surnames when no Tree is loaded, I’d like it to branch to telling the user that a Tree needs to be loaded or imported so that is could report useful information.

And if no Persons exist in a loaded Tree, I’d like to have a message about that.

A “no database” similar issue is discussed in the following bug report:
https://gramps-project.org/bugs/view.php?id=2092

I’d also like to add the test to the “What’s next?” Gramplet. The first error condition it recognizes is “no home person set”.

The “no database”, “no people record”, and “no active person” conditions ought to pop messages before that.

Test for db open:
if self.dbstate.db.is_open():

Test for people:
people = self.dbstate.db.get_number_of_people()
if not people:

Test for active: Since this Gramplet is not a Person Gramplet, you have to specify what type of object you want to see if active.
active_person = self.get_active(“Person”)
if not active_person: # will be empty string in not active, else person handle
… #

2 Likes

Okay. The What’s Next? gramplet has been modified to start with a series of tests for the Instant Errors every Gramps newbie encounters. The routines use comparisons suggested by @prculley :

No tree database loaded:
image

Empty tree:
image

This one doesn’t work right yet. The test ALWAYS thinks that there is no Active Person
Tree with people but no Active Person:
image

Active Person but no Home Person:
image

The ‘active’ test probably is not working if one of the people views has not been started yet.

1 Like

How should a gramplet monitor if a Database has been unloaded or loaded?

This gramplet does not reinitialize when either of those 2 event occur… and it needs to do so.

As an aside, Nick suggested changing some of the Grampet’s refresh control code to take advantage of the CallbackManager to make refresh more efficient. (And that will help the other parts of the Gramplet.) However, reading the source suggests that it is supposed to be destroyed when the database is swapped out. So it seems unlikely to have signals I can use for that.

The following old bug report discussed handling certain error conditions when no database is loaded. And implementation of a dummy.db and various refresh problems… including Gramplets that don’t Clear when the database has just been unloaded. The last exchange didn’t mention any patches to make the Gramplets more aware.
0002092: Problems when no database is open

I’ve seen mention of the dummy.db so it seems like at least part of the approach was implemented. But it is hard to tell where things stand now.

However, the Gramplet does show useful information stepping a newbie through if no Tree was originally loaded… or if starting with a blank tree:

You need to connect to the ‘database-changed’ signal in the DbState class. The DbGUIElement class is often useful when using the callback manager.

1 Like

After searching for awhile for an example in an existing gramplet (discovered in Form Gramplet) and the Sphinx developer documentation: