How to get current value of objects?

Context

I compute a tooltip when the mouse hovers over “hot data” in a Note. This is “synthesis” of bits extracted from several “objects” (Notes associated with Repository, Source and Citation).

For the general idea, see Request for comment: dynamically synthesised URLs

Retrieving the “bits” requires traversing backlinks which have no explicit fields or pointers in the “objects” (they are reverse relationships).

I do this by querying the database and optionally following direct links when needed/possible. This works fine, except for a “glitch”.

Problem

When one of the “objects” is currently edited, DB query returns the stored state, not the current one in the edit window. This constrains me to save the edit window to see the “current” tooltip. But, if I am not satisfied with the result, I can no longer simply cancel my modification because it has been committed to the DB and I lost the previous value. I can’t use the Undo History because the sequence of commits is not necessarily in an order compatible with the “erratic” edition history.

I wonder if I can completely skip saves to the DB by referencing directly the “objects” while they are edited.

Questions

Is there a way to retrieve the list of objects currently in “editing state”, i.e. opened in a window?

And, assuming such a list is possible, how to get a reference to the occurrence of the “object”?

How can I check if the “object” has a corresponding record in the DB (not necessarily up-to-date)?

It sounds like what you are describing is a “cache”. When you edit data then the cache is outdated.

I think the only thing you could do would be to update the cache with the in-memory data.

You could have a “mock” database where you saved the data to, but really the only thing it would do would be to update the cache.

Does that help?

The notion of “cache” implies that I heavily process the database, which is not the case.

You’ll better understand my need after I describe my concern.

I was confronted recently with internet “URL-decay” when I decided to check my citation links to online archives. It revealed that ~4k URLs had become invalid.

Analysing the situation, I found the main reasons were:

  • change in host name
  • change in management software resulting in a different URL structure
  • change in document designation

These can be “comfortably” addressed if I can split the URL into various “components” I can store at adequate layer in the Repository-Source-Citation model so that in case of later changes I only need to modify only one record to update all dependent ones.

I am presently in a bulk job, I hope to be done only once or so, of “translating” full URLs into fragments. This requires tuning the various fragments to find the simplest, elegant and straightforward form. While doing so a Repo window, a Source one and Citation(s) are opened. While I hover over the Citation fragment, I check that the generated parts (both “label” and URL) are “correct”. If they aren’t, I fix the other fragments until satisfied.

Under normal circumstances, none of the records in the Repo-Source-Citation chain are open for edition and data from the DB is used. However, during this conversion stage, I want something more straightforward than saving to DB and reopening the window. This is an “exceptional” process. I don’t want to go for a “cache” implementation which is probably too much (and difficult to debut and maintain) for a temporary step in my harvest.

Are you asking about the active object?

Such as when @Urchello populates a tooltip for an indicated option based on data from the Active Object?

Or when SuperTool transits the selected objects:

Script: find the Secondary objects, augments the References tab in People object editor.

What is your definition of “active object”? The one currently selected in a list window?

If so, no. I find the “objects” on a chain and I want to make sure they are not currently edited. If they aren’t, value in the DB is the current one. If they are, value in the DB is potentially stale and I must reference values in the edit window.

I may have a clue based on the Windows menu. Perhaps, I could traverse the data structure to see if one of my “objects” is in the structure. To be studied.

I know about find_backlink_handles(…) and I use it to build my chain. The question is about “freshness” of data in the DB.

Regarding the reliance on links: I have personally stopped trusting so-called ‘permanent links,’ even from national and international archives.

A prime example is the National Archives of Norway (Digitalarkivet), which has changed its ‘permanent link’ structure at least three times in the last 25 years. Every time they update their database or website architecture, thousands of carefully documented links in genealogy databases around the world break. This is why I believe it is crucial to store the actual current value and data of an object locally within Gramps or other software used, rather than just pointing to an external URL.

To address this, I rely on a strict citation workflow.
I use Zotero to manage all my bibliography and citations. I primarily use the APA style, as it is the most common standard in Norway, but Zotero makes it easy to generate multiple correctly formatted strings. I manually add details like ‘page’, ‘section’, or ‘line’ to the string whenever needed—mostly because I am lazy and haven’t bothered to automate this in Zotero, as I don’t always want these details included, such as when making more general references to a source.

I manually copy these complete citation or bibliography strings into a Gramps Note and to the Vol./Page and Pub. Info fields, including a direct link to the corresponding Zotero object. I also always ensure I have a fully qualifying name for both sources and citations in the title field in Gramps (or as the name/title in other software). Every single entry includes an ‘Accessed on [Date]’ or ‘As of [Date]’ note.

I also include the ‘permanent’ (or not so permanent) link along with any other metadata provided by the archive in a Gramps Note, again tagged with ‘As of [Date]’. Furthermore, I perform a complete backup of my entire Zotero library along with all other program data. My Gramps media archive points to the same directory structure where I store all my downloaded source documents in Zotero. I use linked files rather than Zotero’s internal storage structure.

This directory structure is mirrored across all the software I use. To simplify further, I am in the process of consolidating my source archive with my general photo and video archives—even for non-genealogical content. I simply use subfolders to differentiate categories and point the respective programs to the correct level in the hierarchy. This ensures I always have at least one local, offline copy of every source I’ve found.


As a digression: I also maintain a dedicated folder for the installation files of all active programs I use. Whenever I update a program, the new installer is added to my backup. This ensures I always have access to the correct software versions, which can be set up to read my existing data structure with minimal effort. If a program can be run ‘standalone’ (installation-free), I keep those ready in a folder named ‘Active Software’ within the same structure.

By doing this, I ensure that even if the URL breaks or the archive reorganizes its database for the fourth time, I still have the full bibliographic record, the exact context, and the actual source file. A link should only be a secondary reference; a proper citation and local data is the actual evidence.


Author’s Note: This text was originally written in Norwegian and later translated and edited for clarity with the assistance of Google AI. Some structural adjustments were made during the process to improve coherence, but all analytical content and conclusions remain my own.


I do the same to always have the data at hand. However, I don’t fully trust myself (typos, copy errors, original record reading ambiguity, …) and I want to keep a “permalink” in order to check my interpretation some time later.

This is where my newly implemented feature is useful. No later than last week, a software update at my most used archive institution invalidated the permalinks. Fortunately enough, I was in the process of converting explicit URLs to my “fragmented links”.

A quick analysis revealed that the URL syntax underwent a minor change. My fragments are structured so that they describe this syntax in the repository layer (handing over the needed fragments to the source and citation layers). I only patched one line in the repository note and all the permalinks became live again.

I was very happy with the confirmation of my abstract concept of so-called “fragmented links”. I’ll continue with testing before proposing it officially. However, average genealogists not familiar with formal logic may find the feature “contorted”.

I looked at GrampsWindowManager class. It maintains a list of all currently open windows in its window_tree private variable. This is what I need.

Does anyone know how I can access the active instance of GrampsWindowManager?

It is referenced only once (creation time) on instantiation of DisplayState, itself instantiated in function _build_main_window() of ViewManager initialisation, which ends up in Gramps instantiation.

Unfortunately the latter is not kept in any variable. How can I access any of the singletons in this chain? It must be available from anywhere without creating new dependencies.

This is one of the reasons why I use a Bibliography and Citation manager like Zotero and have advocated for support for CSL and e.g. CSL-JSON…

It is just a little easier to manage sources and citations in a dedicated software that gives standardized citation- and bibliography strings automatically…

But of course, the problem with rotten links are still a big problem, even in those programs, but at least, in those, it is possible to store the metadata in a proper way, so it can be a little easier to fix those type of problems…