but if you save the same code as a regular Gramps filter this error occurs:
2023-01-22 14:19:02.741: ERROR: grampsapp.py: line 157: Unhandled exception
Traceback (most recent call last):
File "C:\Program Files\GrampsAIO64-5.1.3\gramps\gui\filters\sidebar\_sidebarfilter.py", line 112, in clicked
self.clicked_func()
File "C:\Program Files\GrampsAIO64-5.1.3\gramps\plugins\gramplet\filter.py", line 61, in __filter_clicked
self.gui.view.build_tree()
File "C:\Program Files\GrampsAIO64-5.1.3\gramps\gui\views\listview.py", line 328, in build_tree
self.model.rebuild_data()
File "C:\Program Files\GrampsAIO64-5.1.3\gramps\gui\views\treemodels\flatbasemodel.py", line 618, in _rebuild_filter
user=self.user)
File "C:\Program Files\GrampsAIO64-5.1.3\gramps\gen\filters\_genericfilter.py", line 262, in apply
rule.requestprepare(db, user)
File "C:\Program Files\GrampsAIO64-5.1.3\gramps\gen\filters\rules\_rule.py", line 91, in requestprepare
self.prepare(db, user)
File "C:\Program Files\GrampsAIO64-5.1.3\gramps\gen\filters\rules\_matchesfilterbase.py", line 65, in prepare
rule.requestprepare(db, user)
File "C:\Program Files\GrampsAIO64-5.1.3\gramps\gen\filters\rules\_rule.py", line 91, in requestprepare
self.prepare(db, user)
File "C:\Users\1\AppData\Roaming\gramps\gramps51\plugins\SuperTool\supertool_genfilter.py", line 131, in prepare
dbstate, None, s, self.init_env, "exec"
File "C:\Users\1\AppData\Roaming\gramps\gramps51\plugins\SuperTool\supertool_engine.py", line 763, in execute_source
return execute(dbstate, obj, code, SourceProxy, envvars, exectype)
File "C:\Users\1\AppData\Roaming\gramps\gramps51\plugins\SuperTool\supertool_engine.py", line 724, in execute
res = exec(code, env)
File "initial_statements", line 1168, in <module>
NameError: name 'db' is not defined
Code generating that error while used as a regular filter:
[Gramps SuperTool script file]
version=1
[title]
SuperTool-Sources
[category]
Sources
[initial_statements]
@include ST_filters_init.py
# Valeurs modifiables - début
rnoteContent_recherche = STF_note_content(note_content = "recherche", db=db)
rnoteContent_systematique = STF_note_content(note_content = "systématique", db=db)
# Valeurs modifiables - fin
[statements]
rnoteContent_recherche.recherche(namespace=namespace, gramps_id=gramps_id, notes=notes)
rnoteContent_systematique.recherche(namespace=namespace, gramps_id=gramps_id, notes=notes)
[filter]
gramps_id in rnoteContent_recherche.gid and gramps_id in rnoteContent_systematique.gid
[expressions]
gramps_id
[scope]
all
[unwind_lists]
False
[commit_changes]
False
[summary_only]
False
db property is available in Supertool window:![](https://dl.dropbox.com/s/btgg31onc9fklqn/Capture%20d%E2%80%99%C3%A9cran%202023-01-22%20143651.jpg)
but if you save the same code as a regular Gramps filter this error occurs:
Code generating that error while used as a regular filter:
Included library is there: https://www.dropbox.com/s/3xakwuepz93fbm1/ST_filters_init.py?dl=0
I'm using Supertool V1.2.5