Thanks.

By looking at order, this could work as expected!
Not certain for complex sequences like multiple active primary objects?

gramps/gen/db/read.py:1138: def _f(curs_):
gramps/gen/db/read.py:1150: iter_person_handles = _f(get_person_cursor)
gramps/gen/db/read.py:1151: iter_family_handles = _f(get_family_cursor)
gramps/gen/db/read.py:1152: iter_event_handles = _f(get_event_cursor)
gramps/gen/db/read.py:1153: iter_place_handles = _f(get_place_cursor)
gramps/gen/db/read.py:1154: iter_source_handles = _f(get_source_cursor)
gramps/gen/db/read.py:1155: iter_citation_handles = _f(get_citation_cursor)
gramps/gen/db/read.py:1156: iter_media_object_handles = _f(get_media_cursor)
gramps/gen/db/read.py:1157: iter_repository_handles = _f(get_repository_cursor)
gramps/gen/db/read.py:1158: iter_note_handles = _f(get_note_cursor)
gramps/gen/db/read.py:1159: iter_tag_handles = _f(get_tag_cursor)

gramps/gen/db/read.py:1162: def _f(curs_, obj_):
gramps/gen/db/read.py:1176: iter_people = _f(get_person_cursor, Person)
gramps/gen/db/read.py:1177: iter_families = _f(get_family_cursor, Family)
gramps/gen/db/read.py:1178: iter_events = _f(get_event_cursor, Event)
gramps/gen/db/read.py:1179: iter_places = _f(get_place_cursor, Place)
gramps/gen/db/read.py:1180: iter_sources = _f(get_source_cursor, Source)
gramps/gen/db/read.py:1181: iter_citations = _f(get_citation_cursor, Citation)
gramps/gen/db/read.py:1182: iter_media_objects = _f(get_media_cursor, MediaObject)
gramps/gen/db/read.py:1183: iter_repositories = _f(get_repository_cursor, Repository)
gramps/gen/db/read.py:1184: iter_notes = _f(get_note_cursor, Note)
gramps/gen/db/read.py:1185: iter_tags = _f(get_tag_cursor, Tag)


Note, even for private functions only, to use the same name is really confusing.

Jérôme

Le sam. 10 mai 2014 at 8:39, Vassilii Khachaturov <vassilii@tarunz.org> a écrit :
On 09.05.2014 22:01, Jerome wrote:
Devs,

By looking if I can fix some errors, I found maybe a possible major issue.
https://gramps-project.org/bugs/view.php?id=7678#c36153

One method is set twice on gen/db/read.py!

If there is no difference between:

def _f(curs_):
        """
        Closure that returns an iterator over handles in the database.
        """
        def g(self):
            with curs_(self) as cursor:
                for key, data in cursor:
                    yield handle2internal(key)
        return g
and:

    def _f(curs_, obj_):
        """
        Closure that returns an iterator over objects in the database.
        """
        def g(self):
            with curs_(self) as cursor:
                for key, data in cursor:
                    obj = obj_()
                    obj.unserialize(data)
                    yield obj
        return g

then this could be minor, 
but this could be also the cause of some recent bugs under 4.0.x!

Which one is the good one?


Things are evaluated in order of appearance. So if you have a

def foo(bar):
  ...
def foo(bar, baz):
  ...

then anything after the block will see the 2nd definition only, overriding the 1st and obliterating it forever. (Unless something aliases the 1st foo in betwen, e.g.
def foo(bar):
  ...
preserved_foo = foo
def foo(bar, baz):
  ...