# Need help getting started with a new addon

**URL:** <https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941>\
**Category:** Development\
**Tags:** third-party-addon, timeline\
**Created:** [October 28, 2022, 5:59pm UTC](https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941 "2022-10-28T17:59:50Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![JohnS](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/johns/32/2082_2.png) [@JohnS](https://gramps.discourse.group/u/JohnS)\
**Post date:** [October 28, 2022, 5:59pm UTC](https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941/1 "2022-10-28T17:59:50Z")

</div>

I’m trying to develop a text report addon that would generate a table where the columns are persons selected using something like the “People of Interest” menu from “Family Lines Graph” graph. The rows would years, but with multiple lines per year similar to the 'Family Sheet" text report. I’m calling it “Timeline Contingency Report”. So far I have managed to:

- read through parts of addons development wiki ([Addons development - Gramps](https://gramps-project.org/wiki/index.php/Addons_development))
- created a user on my computer who exists only to modify gramps.
- forked gramps, addons, and addons-source to my github account ([johnrsibert (John Sibert) · GitHub](https://github.com/johnrsibert)) and cloned to my local computer
- created timelinecontingency.gpr.py timelinecontingency.py in the [TimelineContingency](https://github.com/johnrsibert/addons-source/tree/master/TimelineContingency)/ directory
- attempted to test the code

But I seem to be unable to “register” the new code. Timeline Contingency does not appear in any menu, and I’m finding in information in the Wiki a trifle non-specific.

I would grateful for any constructive suggestions.

---

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [October 28, 2022, 7:32pm UTC](https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941/2 "2022-10-28T19:32:19Z")

</div>

> [@JohnS](#):
>
> But I seem to be unable to “register” the new code. Timeline Contingency does not appear in any menu, and I’m finding in information in the Wiki a trifle non-specific.

Welcome!

On [lines 16-17](https://github.com/johnrsibert/addons-source/blob/9ddc20fc326f68ac5c21e06a9ed4cad39165901b/TimelineContingency/timelinecontingency.gpr.py#L16) of your Gramps Plugin Registration file, it starts to double register the Report add-on and in the wrong (Tool) class. (You definitely want to run Gramps from the Console while debugging. That’s where the Registration error appeared that helped find this problem.)

Remove lines 16 & 17 and the Report registers successfully with no errors reported to the console. And now **Timeline Contingency…** appears in the Reports → Text Reports menu.

However, attempting to load the report echos the following messages to the Console:

```python
Traceback (most recent call last):
  File "C:\Program Files\GrampsAIO64-5.1.5\gramps\gen\plug\_manager.py", line 252, in load_plugin
    _module = self.import_plugin(pdata)
  File "C:\Program Files\GrampsAIO64-5.1.5\gramps\gen\plug\_manager.py", line 285, in import_plugin
    module = __import__ (pdata.mod_name)
  File "C:\Users\DistrictSupport\AppData\Roaming\gramps\gramps51\plugins\TimeContingency\timelinecontingency.py", line 67
    Class TimelineContingencyReport(Report)
                                  ^
SyntaxError: invalid syntax

```

---

<div class="post-metadata">

**Author:** ![JohnS](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/johns/32/2082_2.png) [@JohnS](https://gramps.discourse.group/u/JohnS)\
**Post date:** [October 29, 2022, 6:13pm UTC](https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941/3 "2022-10-29T18:13:50Z")

</div>

Thanks for finding those errors. I deleted lines 16 and 17. When I tested the change, two errors occurred:  
First there seemed to be some sort of conflict loading my family trees. I checked the version in the gramps help and it came up with 5.2.  
Second, when I changed ‘gramps\_target\_version’ in the registration file to 5.2. The family tree loaded, but Timeline Contingency did not appear in the Reports → Test Reports menu.  
I think I may have forked the wrong code. As I mentioned I’m finding the wiki a bit non-specific.

The code in timelinecontingency.py is mainly place holder, and I would not expect it to run correctly if at all. My first priority is getting the thin to show up on the menu.

---

<div class="post-metadata">

**Author:** ![codefarmer](https://avatars.discourse-cdn.com/v4/letter/c/b9e5f3/32.png) [@codefarmer](https://gramps.discourse.group/u/codefarmer)\
**Post date:** [October 29, 2022, 10:11pm UTC](https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941/4 "2022-10-29T22:11:39Z")

</div>

@JohnS Are testing your new addon against a built (or installed) copy of Gramps 5.1.x? It sounds like you may be testing your addon against the latest code from gramps `master` branch which is [versioned at 5.2](https://github.com/gramps-project/gramps/blob/master/gramps/version.py) (next release). Unless your work requires Gramps 5.2, it’s probably better to target 5.1.

Typically when I work on changes (usually bug fixes) I create a new branch from the `maintenance/gramps51` branch of the source, and I test changes against the installed version of Gramps 5.1.x on my system. Of course if you have a full-fledged gramps development environment, you can build and run `maintenance/gramps51` branch too.

You’re probably familiar with git branching, but the wiki has steps on how to create a branch for developing against 5.1 near the end of this section: [Get a local copy of Gramps and its addons](https://gramps-project.org/wiki/index.php/Addons_development#Get_a_local_copy_of_Gramps_and_its_addons).

---

<div class="post-metadata">

**Author:** ![JohnS](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/johns/32/2082_2.png) [@JohnS](https://gramps.discourse.group/u/JohnS)\
**Post date:** [October 30, 2022, 3:08pm UTC](https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941/5 "2022-10-30T15:08:39Z")

</div>

I am trying to target version 5.1. But I was confused by suggestions in one of the development wiki pages. Executing gramps/Gramps.py’ starts v5.2.0, whereas executing gramps/scripts/gramps’ starts v5.1.2. Starting in Gnome terminal desktop emulator.

$uname -a  
Linux kihikihi 5.4.0-128-generic #144-Ubuntu SMP Tue Sep 20 11:00:04 UTC 2022 x86\_64 x86\_64 x86\_64 GNU/Linux

---

<div class="post-metadata">

**Author:** ![JohnS](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/johns/32/2082_2.png) [@JohnS](https://gramps.discourse.group/u/JohnS)\
**Post date:** [October 31, 2022, 10:25pm UTC](https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941/6 "2022-10-31T22:25:32Z")

</div>

At my wits end: still unable to get my new addon to appear in the Reports\>Text Report menu.

I resolved the gramps version question and managed to get gramps/scripts/gramps to load my family tree. But still no success with getting my TimelineContingency addon to appear in a menu.

---

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [October 31, 2022, 11:14pm UTC](https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941/7 "2022-10-31T23:14:12Z")

</div>

Strange. The menu item appeared after creating a `TimeContingency` folder in my [Gramps User Directory](https://gramps-project.org/wiki/index.php/Gramps_Glossary#user_directory) plugs folder (in Windows, that’s `%appdata%/gramps/gramps51/plugins/TimeContingency`) with your 2 files and changing the Gramps Plugin Registration file to the following:

```auto
register(REPORT,
    id = "TimelineContingency",
    name = _("Timeline Contingency"),
    description = _("Creates a timeline table for selected persons."),
    version = "1.0.1",
    gramps_target_version = "5.1",
    status = STABLE,
    fname = "timelinecontingency.py",
    authors = ["John R. Sibert"],
    authors_email = ["johnrsibert@gmail.com"],
    category = CATEGORY_TEXT,
    reportclass = "TimelineContingency",
    optionclass = "TimelineContingency",
    report_modes = [REPORT_MODE_CLI, REPORT_MODE_GUI, REPORT_MODE_BKI],
    require_active = False,
    )

```

Although it appeared on the Tools → Text Reports submenu, here is its listing in the Report Selection dialog (launched from the ![image](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/e/ec390df2b74242b2b06a64306c37525eaa0fddd9.png)  
[button on the Toolbar](https://gramps-project.org/wiki/index.php/Gramps_5.1_Wiki_Manual_-_Navigation#Open_the_reports_dialog).)

 ![image](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/9/92acfea3a90f53466e032997fa263ea49579be1d.png)

---

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [October 31, 2022, 11:36pm UTC](https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941/8 "2022-10-31T23:36:29Z")

</div>

Make certain that the Gramps version number in the path to the plugins folder matches the version of Gramps that you are running.

You indicated you had a 5.2 prototype installed as well as the 5.1 general release version. The `.gpr.py` is a 5.1 version. So the addon has to be installed in the `gramps/gramps51/plugins/` subfolder and you have to launch that 5.1 version of Gramps.

---

<div class="post-metadata">

**Author:** ![JohnS](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/johns/32/2082_2.png) [@JohnS](https://gramps.discourse.group/u/JohnS)\
**Post date:** [November 1, 2022, 4:53pm UTC](https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941/9 "2022-11-01T16:53:34Z")

</div>

It appears that I neglected to build gramps from source after I downloaded to my local repo. I’m not able to specify version 5.1. The build script insists on building 5.2. I have the feeling that I should start again from zero. I’m building as a unique user to protect my standard installation.

---

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [November 1, 2022, 5:22pm UTC](https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941/10 "2022-11-01T17:22:34Z")

</div>

Before you start from scratch…

Manually tweak the TimeContingency report folder in your local Gramps 5.1 plugins folder. Ignore the build scripts for this simple test.

If you don’t have a copy of your addon in that plugins folder, drag a copy there and use a simple text Editor (like Notepad++) to change the target version in the `.gpr.py` file.

The report should then build & show up in your menus.

A bit of success will go a long way towards reducing your frustration level… which makes any next steps less aggravating.

---

<div class="post-metadata">

**Author:** ![JohnS](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/johns/32/2082_2.png) [@JohnS](https://gramps.discourse.group/u/JohnS)\
**Post date:** [November 1, 2022, 6:23pm UTC](https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941/11 "2022-11-01T18:23:21Z")

</div>

Hah! Small success indeed.  
Pasting the TimelineContingency report folder in my local gramps51 plugins folder.  
However, pasting it into my gramps52 editing the gpr file to version 5.2 (with vim) caused the adddon to appear in the menu. It even produced the expected output and error.

So a bit of success. But I think I need to be targeting gramps 5.1. No?

Thanks for your help and patience.

---

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [November 1, 2022, 6:45pm UTC](https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941/12 "2022-11-01T18:45:45Z")

</div>

> [@JohnS](#):
>
> But I think I need to be targeting gramps 5.1. No?

Unless your report uses features only available in the new 5.2 core, then YES! Definitely target 5.1 version.

Your pool of available beta testers (& Weblate translators) will be too small with a 5.2 target.

---

<div class="post-metadata">

**Author:** ![JohnS](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/johns/32/2082_2.png) [@JohnS](https://gramps.discourse.group/u/JohnS)\
**Post date:** [November 3, 2022, 4:15pm UTC](https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941/13 "2022-11-03T16:15:13Z")

</div>

I decided to start again from scratch and I’m following guidance in the [Addons Development Wiki](https://gramps-project.org/wiki/index.php/Addons_development). The wiki advises

> To test your addon as you develop it is suggested that you copy your NewProjectName plugin into your Gramps user plugin directory from your addon development directory, prior to testing. Or just edit in the Gramps user plugin directory until it is ready to publish, then copy back to your addon development directory.
> 
> Your installed Gramps will search this folder (and subdirectories) for .gpr.py files, and add them to the plugin list.

The result is positive. My currently installed gramps software recognizes my new addon and executes it as expected.

However, the wiki advice runs contrary to my usual workflow with with github hosted code, which includes frequent commits to a forked repo. Copying new code back and forth between two directories is a bother and an invitation to error. So my instinct was to simply use a soft link eg  
**ln -s ~/GrampsTesting/addons-source/TimelineContingency/ ~/.gramps/gramps51/plugins** , but when I tried the soft link, my gramps did not recognize the new addon.

So, two questions: (1) is it necessary to build gramps from source if one is simply writing a new addon; (2) is soft link problem linux quirk that I’n not understanding or a gramps feature?

Thanks again for all your attention and help.

---

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [November 3, 2022, 4:49pm UTC](https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941/14 "2022-11-03T16:49:35Z")

</div>

I could help with diagnosing the registration file but am out of my depth when the GitHub side is involved.

As a dilettante, my exploring Python environment has been just been Notepad++ and Isotammi’s SuperTool add-on. (With cursory forays into PyCharm & Glade. ‘Curse’ being the operative term.)

Other than forking Gramps – which I deleted this week, my first use of personal repositories was yesterday!

We need to attract the mentoring attention of an experienced Gramps developer. @Nick-Hall , could you invite a developer with experience posting Report add-ons?

---

<div class="post-metadata">

**Author:** ![Nick-Hall](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/nick-hall/32/95_2.png) [@Nick-Hall](https://gramps.discourse.group/u/Nick-Hall)\
**Post date:** [November 3, 2022, 5:28pm UTC](https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941/15 "2022-11-03T17:28:26Z")

</div>

> [@JohnS](#):
>
> (1) is it necessary to build gramps from source if one is simply writing a new addon

No.

> [@JohnS](#):
>
> (2) is soft link problem linux quirk that I’n not understanding or a gramps feature?

Looking at the [code](https://github.com/gramps-project/gramps/blob/master/gramps/gen/plug/_manager.py#L133), the `plugins` directory itself can be a symbolic link, but links are not followed when searching sub-directories with [os.walk](https://docs.python.org/3.8/library/os.html#os.walk). We do not specify `followlinks=True`.

---

<div class="post-metadata">

**Author:** ![JohnS](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/johns/32/2082_2.png) [@JohnS](https://gramps.discourse.group/u/JohnS)\
**Post date:** [November 3, 2022, 9:33pm UTC](https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941/16 "2022-11-03T21:33:25Z")

</div>

Thanks for the reply. Presumably on would need to change lines 133-134 to

```auto
for (dirpath, dirnames, filenames) in os.walk(direct, followlinks=True
                                                          topdown=True):

```

which would require a build from source

---

<div class="post-metadata">

**Author:** ![Nick-Hall](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/nick-hall/32/95_2.png) [@Nick-Hall](https://gramps.discourse.group/u/Nick-Hall)\
**Post date:** [November 3, 2022, 9:38pm UTC](https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941/17 "2022-11-03T21:38:48Z")

</div>

You don’t need to build from source if you modify the code. I don’t suggest that you modify your production code though, unless you know what you are doing.

The build is mainly used for translations and manual pages, but it does build a few xml files.

---

<div class="post-metadata">

**Author:** ![anon9092048](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@anon9092048](https://gramps.discourse.group/u/anon9092048)\
**Post date:** [November 3, 2022, 9:39pm UTC](https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941/18 "2022-11-03T21:39:04Z")

</div>

Was about to raise it as an issue but can see one already !

- [0010436: Symlinks to folders in gramps plugin dir are not scanned](https://gramps-project.org/bugs/view.php?id=10436)

---

<div class="post-metadata">

**Author:** ![codefarmer](https://avatars.discourse-cdn.com/v4/letter/c/b9e5f3/32.png) [@codefarmer](https://gramps.discourse.group/u/codefarmer)\
**Post date:** [November 4, 2022, 8:05pm UTC](https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941/19 "2022-11-04T20:05:36Z")

</div>

> [@JohnS](#):
>
> I’m not able to specify version 5.1. The build script insists on building 5.2.

This is a bit late as you’ve progressed since and it would be better to stay with your setup if you’ve got it working.

However, you can try this when you’re ready to experiment again, or experiment in a separate source tree. Once you clone gramps and addons-source git repos, to work in gramps51 you can switch both repos to the `origin/maintenance/gramps51` branch.

When you start new work, you can create a branch starting at the commit for `origin/maintenance/gramps51` so you can develop code compatible with 5.1.

Git has a feature called ‘worktree’ which is also very helpful in creating a separate worktrees for working with different versions, but that’s a topic for another day.

---

<div class="post-metadata">

**Author:** ![JohnS](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/johns/32/2082_2.png) [@JohnS](https://gramps.discourse.group/u/JohnS)\
**Post date:** [November 5, 2022, 10:50pm UTC](https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941/20 "2022-11-05T22:50:24Z")

</div>

Thanks, but for nowI’m working around the symlink “problem” by simply copying files as needed using a simple bash script.

Nevertheless, I’m still missing something: The Report appears in the menu as expected, but does not seem to execute correctly. It seems to simply fall through code and exit with the message  
AttributeError: type object ‘TimelineContingency’ has no attribute ‘load\_previous\_values’  
running from my standard installation of gramps 5.1

[Next page](https://gramps.discourse.group/t/need-help-getting-started-with-a-new-addon/2941.md?page=2)
