2007-01-22 Alex Roitman <shura@gramps-project.org>
* src/Editors/_EditSource.py (query_response): Remove sourcerefs from repos (indirectly, through secondary objects). * src/Editors/_EditPlace.py (query_response): Avoid db walk. * src/DataViews/_FamilyList.py (remove): Set busy cursor. * src/DataViews/_PlaceView.py (remove): Set busy cursor. * src/DataViews/_SourceView.py (remove): Set busy cursor. * src/DataViews/_MediaView.py (remove): Set busy cursor. * src/DataViews/_EventView.py (remove): Set busy cursor. * src/DataViews/_RepositoryView.py (remove): Set busy cursor. * src/Editors/_EditEventRef.py (DelEventQuery): Remove unneeded class. * src/Filters/Rules/_HasTextMatchingSubstringOf.py: Remove unneeded import. * src/Filters/Rules/Person/_HasTextMatchingSubstringOf.py (cache_sources): Adapt to changes in get_source_referents. * src/Utils.py (get_source_referents): Use reference map, add repositories to the search results; (get_media_referents): Use reference map. svn: r7958
This commit is contained in:
parent
8582d6b11e
commit
58b1a424bb
19
ChangeLog
19
ChangeLog
@ -1,3 +1,22 @@
|
||||
2007-01-22 Alex Roitman <shura@gramps-project.org>
|
||||
* src/Editors/_EditSource.py (query_response): Remove sourcerefs
|
||||
from repos (indirectly, through secondary objects).
|
||||
* src/Editors/_EditPlace.py (query_response): Avoid db walk.
|
||||
* src/DataViews/_FamilyList.py (remove): Set busy cursor.
|
||||
* src/DataViews/_PlaceView.py (remove): Set busy cursor.
|
||||
* src/DataViews/_SourceView.py (remove): Set busy cursor.
|
||||
* src/DataViews/_MediaView.py (remove): Set busy cursor.
|
||||
* src/DataViews/_EventView.py (remove): Set busy cursor.
|
||||
* src/DataViews/_RepositoryView.py (remove): Set busy cursor.
|
||||
* src/Editors/_EditEventRef.py (DelEventQuery): Remove unneeded class.
|
||||
* src/Filters/Rules/_HasTextMatchingSubstringOf.py: Remove
|
||||
unneeded import.
|
||||
* src/Filters/Rules/Person/_HasTextMatchingSubstringOf.py
|
||||
(cache_sources): Adapt to changes in get_source_referents.
|
||||
* src/Utils.py (get_source_referents): Use reference map, add
|
||||
repositories to the search results;
|
||||
(get_media_referents): Use reference map.
|
||||
|
||||
2007-01-22 Douglas Blank <dblank@cs.brynmawr.edu>
|
||||
* src/plugins/Calendar.py: 0000858: Patch for calendar enhancements and new
|
||||
Birthday Report
|
||||
|
@ -201,7 +201,8 @@ class EventView(PageView.ListView):
|
||||
|
||||
event = db.get_event_from_handle(ehandle)
|
||||
|
||||
ans = DelEventQuery(event, db, person_list, family_list)
|
||||
ans = DelEventQuery(self.dbstate,self.uistate,
|
||||
event,person_list,family_list)
|
||||
|
||||
if len(person_list) + len(family_list) > 0:
|
||||
msg = _('This event is currently being used. Deleting it '
|
||||
@ -215,8 +216,10 @@ class EventView(PageView.ListView):
|
||||
if descr == "":
|
||||
descr = event.get_gramps_id()
|
||||
|
||||
self.uistate.set_busy_cursor(1)
|
||||
QuestionDialog(_('Delete %s?') % descr, msg,
|
||||
_('_Delete Event'), ans.query_response)
|
||||
self.uistate.set_busy_cursor(0)
|
||||
|
||||
def edit(self, obj):
|
||||
mlist = []
|
||||
@ -228,4 +231,3 @@ class EventView(PageView.ListView):
|
||||
EditEvent(event, self.dbstate, self.uistate)
|
||||
except Errors.WindowActiveError:
|
||||
pass
|
||||
|
||||
|
@ -177,6 +177,7 @@ class FamilyListView(PageView.ListView):
|
||||
pass
|
||||
|
||||
def remove(self, obj):
|
||||
self.uistate.set_busy_cursor(1)
|
||||
import GrampsDb
|
||||
|
||||
mlist = []
|
||||
@ -185,6 +186,7 @@ class FamilyListView(PageView.ListView):
|
||||
for handle in mlist:
|
||||
GrampsDb.remove_family_relationships(self.dbstate.db, handle)
|
||||
self.build_tree()
|
||||
self.uistate.set_busy_cursor(0)
|
||||
|
||||
def edit(self, obj):
|
||||
mlist = []
|
||||
|
@ -58,7 +58,7 @@ import Bookmarks
|
||||
import Mime
|
||||
import RelLib
|
||||
|
||||
from Editors import EditMedia
|
||||
from Editors import EditMedia, DeleteMediaQuery
|
||||
import Errors
|
||||
from QuestionDialog import QuestionDialog
|
||||
from Filters.SideBar import MediaSidebarFilter
|
||||
@ -311,7 +311,7 @@ class MediaView(PageView.ListView):
|
||||
return
|
||||
the_lists = Utils.get_media_referents(handle, self.dbstate.db)
|
||||
|
||||
ans = DeleteMediaQuery(handle, self.dbstate.db, the_lists)
|
||||
ans = DeleteMediaQuery(self.dbstate,self.uistate,handle,the_lists)
|
||||
if filter(None, the_lists): # quick test for non-emptiness
|
||||
msg = _('This media object is currently being used. '
|
||||
'If you delete this object, it will be removed from '
|
||||
@ -320,8 +320,10 @@ class MediaView(PageView.ListView):
|
||||
msg = _('Deleting media object will remove it from the database.')
|
||||
|
||||
msg = "%s %s" % (msg, Utils.data_recover_msg)
|
||||
self.uistate.set_busy_cursor(1)
|
||||
QuestionDialog(_('Delete Media Object?'), msg,
|
||||
_('_Delete Media Object'), ans.query_response)
|
||||
self.uistate.set_busy_cursor(0)
|
||||
|
||||
def edit(self, obj):
|
||||
handle = self.first_selected()
|
||||
@ -333,56 +335,3 @@ class MediaView(PageView.ListView):
|
||||
EditMedia(self.dbstate, self.uistate, [], obj)
|
||||
except Errors.WindowActiveError:
|
||||
pass
|
||||
|
||||
class DeleteMediaQuery:
|
||||
|
||||
def __init__(self, media_handle, db, the_lists):
|
||||
self.db = db
|
||||
self.media_handle = media_handle
|
||||
self.the_lists = the_lists
|
||||
|
||||
def query_response(self):
|
||||
trans = self.db.transaction_begin()
|
||||
self.db.disable_signals()
|
||||
|
||||
(person_list, family_list, event_list,
|
||||
place_list, source_list) = self.the_lists
|
||||
|
||||
for handle in person_list:
|
||||
person = self.db.get_person_from_handle(handle)
|
||||
new_list = [ photo for photo in person.get_media_list() \
|
||||
if photo.get_reference_handle() != self.media_handle ]
|
||||
person.set_media_list(new_list)
|
||||
self.db.commit_person(person, trans)
|
||||
|
||||
for handle in family_list:
|
||||
family = self.db.get_family_from_handle(handle)
|
||||
new_list = [ photo for photo in family.get_media_list() \
|
||||
if photo.get_reference_handle() != self.media_handle ]
|
||||
family.set_media_list(new_list)
|
||||
self.db.commit_family(family, trans)
|
||||
|
||||
for handle in event_list:
|
||||
event = self.db.get_event_from_handle(handle)
|
||||
new_list = [ photo for photo in event.get_media_list() \
|
||||
if photo.get_reference_handle() != self.media_handle ]
|
||||
event.set_media_list(new_list)
|
||||
self.db.commit_event(event, trans)
|
||||
|
||||
for handle in place_list:
|
||||
place = self.db.get_place_from_handle(handle)
|
||||
new_list = [ photo for photo in place.get_media_list() \
|
||||
if photo.get_reference_handle() != self.media_handle ]
|
||||
place.set_media_list(new_list)
|
||||
self.db.commit_place(place, trans)
|
||||
|
||||
for handle in source_list:
|
||||
source = self.db.get_source_from_handle(handle)
|
||||
new_list = [ photo for photo in source.get_media_list() \
|
||||
if photo.get_reference_handle() != self.media_handle ]
|
||||
source.set_media_list(new_list)
|
||||
self.db.commit_source(source, trans)
|
||||
|
||||
self.db.enable_signals()
|
||||
self.db.remove_object(self.media_handle, trans)
|
||||
self.db.transaction_commit(trans, _("Remove Media Object"))
|
||||
|
@ -222,16 +222,22 @@ class PlaceView(PageView.ListView):
|
||||
def remove(self, obj):
|
||||
for place_handle in self.selected_handles():
|
||||
db = self.dbstate.db
|
||||
person_list = [ h for h in
|
||||
db.get_person_handles(False)
|
||||
if db.get_person_from_handle(h).has_handle_reference('Place', place_handle) ]
|
||||
family_list = [ h for h in
|
||||
db.get_family_handles()
|
||||
if db.get_family_from_handle(h).has_handle_reference('Place', place_handle) ]
|
||||
person_list = [
|
||||
item[1] for item in
|
||||
self.dbstate.db.find_backlink_handles(place_handle,['Person'])]
|
||||
|
||||
family_list = [
|
||||
item[1] for item in
|
||||
self.dbstate.db.find_backlink_handles(place_handle,['Family'])]
|
||||
|
||||
event_list = [
|
||||
item[1] for item in
|
||||
self.dbstate.db.find_backlink_handles(place_handle,['Event'])]
|
||||
|
||||
place = db.get_place_from_handle(place_handle)
|
||||
|
||||
ans = DeletePlaceQuery(place, db)
|
||||
ans = DeletePlaceQuery(self.dbstate,self.uistate,
|
||||
place,person_list,family_list,event_list)
|
||||
|
||||
if len(person_list) + len(family_list) > 0:
|
||||
msg = _('This place is currently being used. Deleting it '
|
||||
@ -245,8 +251,10 @@ class PlaceView(PageView.ListView):
|
||||
if descr == "":
|
||||
descr = place.get_gramps_id()
|
||||
|
||||
self.uistate.set_busy_cursor(1)
|
||||
QuestionDialog(_('Delete %s?') % descr, msg,
|
||||
_('_Delete Place'), ans.query_response)
|
||||
self.uistate.set_busy_cursor(0)
|
||||
|
||||
def edit(self, obj):
|
||||
mlist = []
|
||||
@ -272,5 +280,3 @@ class PlaceView(PageView.ListView):
|
||||
else:
|
||||
import Merge
|
||||
Merge.MergePlaces(self.dbstate, self.uistate, mlist[0], mlist[1])
|
||||
|
||||
|
||||
|
@ -188,13 +188,14 @@ class RepositoryView(PageView.ListView):
|
||||
|
||||
for repos_handle in mlist:
|
||||
|
||||
source_list = [ src_handle for src_handle \
|
||||
in db.get_source_handles() \
|
||||
if db.get_source_from_handle(src_handle).has_repo_reference(repos_handle)]
|
||||
source_list = [
|
||||
item[1] for item in
|
||||
self.dbstate.db.find_backlink_handles(repos_handle,['Source'])]
|
||||
|
||||
repository = db.get_repository_from_handle(repos_handle)
|
||||
|
||||
ans = DelRepositoryQuery(repository, db, source_list)
|
||||
ans = DelRepositoryQuery(self.dbstate,self.uistate,
|
||||
repository,source_list)
|
||||
|
||||
if len(source_list) > 0:
|
||||
msg = _('This repository is currently being used. Deleting it '
|
||||
@ -204,9 +205,10 @@ class RepositoryView(PageView.ListView):
|
||||
msg = _('Deleting repository will remove it from the database.')
|
||||
|
||||
msg = "%s %s" % (msg, Utils.data_recover_msg)
|
||||
self.uistate.set_busy_cursor(1)
|
||||
QuestionDialog(_('Delete %s?') % repository.get_name(), msg,
|
||||
_('_Delete Repository'), ans.query_response)
|
||||
|
||||
self.uistate.set_busy_cursor(0)
|
||||
|
||||
def edit(self, obj):
|
||||
mlist = []
|
||||
@ -218,4 +220,3 @@ class RepositoryView(PageView.ListView):
|
||||
EditRepository(self.dbstate, self.uistate, [], repos)
|
||||
except Errors.WindowActiveError:
|
||||
pass
|
||||
|
||||
|
@ -186,7 +186,7 @@ class SourceView(PageView.ListView):
|
||||
|
||||
source = db.get_source_from_handle(source_handle)
|
||||
|
||||
ans = DelSrcQuery(source, db, the_lists)
|
||||
ans = DelSrcQuery(self.dbstate,self.uistate,source,the_lists)
|
||||
|
||||
if filter(None, the_lists): # quick test for non-emptiness
|
||||
msg = _('This source is currently being used. Deleting it '
|
||||
@ -200,8 +200,10 @@ class SourceView(PageView.ListView):
|
||||
if descr == "":
|
||||
descr = source.get_gramps_id()
|
||||
|
||||
self.uistate.set_busy_cursor(1)
|
||||
QuestionDialog(_('Delete %s?') % descr, msg,
|
||||
_('_Delete Source'), ans.query_response)
|
||||
self.uistate.set_busy_cursor(0)
|
||||
|
||||
def edit(self, obj):
|
||||
mlist = []
|
||||
|
@ -295,9 +295,10 @@ class EditFamilyEvent(EditEvent):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DelEventQuery:
|
||||
def __init__(self,event,db,person_list,family_list):
|
||||
def __init__(self,dbstate,uistate,event,person_list,family_list):
|
||||
self.event = event
|
||||
self.db = db
|
||||
self.db = dbstate.db
|
||||
self.uistate = uistate
|
||||
self.person_list = person_list
|
||||
self.family_list = family_list
|
||||
|
||||
|
@ -244,37 +244,3 @@ class EditFamilyEventRef(EditEventRef):
|
||||
def get_custom_events(self):
|
||||
return [ RelLib.EventType((RelLib.EventType.CUSTOM,val)) \
|
||||
for val in self.dbstate.db.get_family_event_types()]
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Delete Query class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DelEventQuery:
|
||||
def __init__(self,event,db,person_list,family_list):
|
||||
self.event = event
|
||||
self.db = db
|
||||
self.person_list = person_list
|
||||
self.family_list = family_list
|
||||
|
||||
def query_response(self):
|
||||
trans = self.db.transaction_begin()
|
||||
self.db.disable_signals()
|
||||
|
||||
ev_handle_list = [self.event.get_handle()]
|
||||
|
||||
for handle in self.person_list:
|
||||
person = self.db.get_person_from_handle(handle)
|
||||
person.remove_handle_references('Event',ev_handle_list)
|
||||
self.db.commit_person(person,trans)
|
||||
|
||||
for handle in self.family_list:
|
||||
family = self.db.get_family_from_handle(handle)
|
||||
family.remove_handle_references('Event',ev_handle_list)
|
||||
self.db.commit_family(family,trans)
|
||||
|
||||
self.db.enable_signals()
|
||||
self.db.remove_event(self.event.get_handle(),trans)
|
||||
self.db.transaction_commit(
|
||||
trans,_("Delete Event (%s)") % self.event.get_gramps_id())
|
||||
|
@ -258,8 +258,9 @@ class EditMedia(EditPrimary):
|
||||
|
||||
class DeleteMediaQuery:
|
||||
|
||||
def __init__(self,media_handle,db,the_lists):
|
||||
self.db = db
|
||||
def __init__(self,dbstate,uistate,media_handle,the_lists):
|
||||
self.db = dbstate.db
|
||||
self.uistate = uistate
|
||||
self.media_handle = media_handle
|
||||
self.the_lists = the_lists
|
||||
|
||||
|
@ -215,9 +215,14 @@ class EditPlace(EditPrimary):
|
||||
#-------------------------------------------------------------------------
|
||||
class DeletePlaceQuery:
|
||||
|
||||
def __init__(self,place,db):
|
||||
self.db = db
|
||||
def __init__(self,dbstate,uistate,
|
||||
place,person_list,family_list,event_list):
|
||||
self.db = dbstate.db
|
||||
self.uistate = uistate
|
||||
self.obj = place
|
||||
self.person_list = person_list
|
||||
self.family_list = family_list
|
||||
self.event_list = event_list
|
||||
|
||||
def query_response(self):
|
||||
trans = self.db.transaction_begin()
|
||||
@ -225,25 +230,22 @@ class DeletePlaceQuery:
|
||||
|
||||
place_handle = self.obj.get_handle()
|
||||
|
||||
for handle in self.db.get_person_handles(sort_handles=False):
|
||||
for handle in self.person_list:
|
||||
person = self.db.get_person_from_handle(handle)
|
||||
if person.has_handle_reference('Place',place_handle):
|
||||
person.remove_handle_references('Place',place_handle)
|
||||
self.db.commit_person(person,trans)
|
||||
person.remove_handle_references('Place',place_handle)
|
||||
self.db.commit_person(person,trans)
|
||||
|
||||
for handle in self.db.get_family_handles():
|
||||
for handle in self.family_list:
|
||||
family = self.db.get_family_from_handle(handle)
|
||||
if family.has_handle_reference('Place',place_handle):
|
||||
family.remove_handle_references('Place',place_handle)
|
||||
self.db.commit_family(family,trans)
|
||||
family.remove_handle_references('Place',place_handle)
|
||||
self.db.commit_family(family,trans)
|
||||
|
||||
for handle in self.db.get_event_handles():
|
||||
for handle in self.event_list:
|
||||
event = self.db.get_event_from_handle(handle)
|
||||
if event.has_handle_reference('Place',place_handle):
|
||||
event.remove_handle_references('Place',place_handle)
|
||||
self.db.commit_event(event,trans)
|
||||
event.remove_handle_references('Place',place_handle)
|
||||
self.db.commit_event(event,trans)
|
||||
|
||||
self.db.enable_signals()
|
||||
self.db.remove_place(place_handle,trans)
|
||||
self.db.transaction_commit(trans,
|
||||
_("Delete Place (%s)") % self.obj.get_title())
|
||||
self.db.transaction_commit(
|
||||
trans,_("Delete Place (%s)") % self.obj.get_title())
|
||||
|
@ -165,15 +165,15 @@ class EditRepository(EditPrimary):
|
||||
Config.sync()
|
||||
|
||||
class DelRepositoryQuery:
|
||||
def __init__(self,repository,db,sources):
|
||||
def __init__(self,dbstate,uistate,repository,sources):
|
||||
self.obj = repository
|
||||
self.db = db
|
||||
self.db = dbstate.db
|
||||
self.uistate = uistate
|
||||
self.sources = sources
|
||||
|
||||
def query_response(self):
|
||||
trans = self.db.transaction_begin()
|
||||
|
||||
|
||||
repos_handle_list = [self.obj.get_handle()]
|
||||
|
||||
for handle in self.sources:
|
||||
|
@ -185,17 +185,18 @@ class EditSource(EditPrimary):
|
||||
Config.sync()
|
||||
|
||||
class DelSrcQuery:
|
||||
def __init__(self,source,db,the_lists):
|
||||
def __init__(self,dbstate,uistate,source,the_lists):
|
||||
self.source = source
|
||||
self.db = db
|
||||
self.db = dbstate.db
|
||||
self.uistate = uistate
|
||||
self.the_lists = the_lists
|
||||
|
||||
def query_response(self):
|
||||
trans = self.db.transaction_begin()
|
||||
self.db.disable_signals()
|
||||
|
||||
(person_list,family_list,event_list,
|
||||
place_list,source_list,media_list) = self.the_lists
|
||||
(person_list,family_list,event_list,place_list,source_list,
|
||||
media_list,repo_list) = self.the_lists
|
||||
|
||||
src_handle_list = [self.source.get_handle()]
|
||||
|
||||
@ -229,6 +230,11 @@ class DelSrcQuery:
|
||||
media.remove_source_references(src_handle_list)
|
||||
self.db.commit_media_object(media,trans)
|
||||
|
||||
for handle in repo_list:
|
||||
repo = self.db.get_repository_from_handle(handle)
|
||||
repo.remove_source_references(src_handle_list)
|
||||
self.db.commit_repository(repo,trans)
|
||||
|
||||
self.db.enable_signals()
|
||||
self.db.remove_source(self.source.get_handle(),trans)
|
||||
self.db.transaction_commit(
|
||||
|
@ -175,9 +175,9 @@ class HasTextMatchingSubstringOf(Rule):
|
||||
if reporef.get_reference_handle() in self.repo_map:
|
||||
match = 1
|
||||
if match:
|
||||
(person_list,family_list,event_list,
|
||||
place_list,source_list,media_list
|
||||
) = get_source_referents(source_handle,self.db)
|
||||
(person_list,family_list,event_list,place_list,source_list,
|
||||
media_list,repo_list
|
||||
) = get_source_referents(source_handle,self.db)
|
||||
for handle in person_list:
|
||||
self.person_map[handle] = 1
|
||||
for handle in family_list:
|
||||
@ -188,6 +188,8 @@ class HasTextMatchingSubstringOf(Rule):
|
||||
self.place_map[handle] = 1
|
||||
for handle in media_list:
|
||||
self.media_map[handle] = 1
|
||||
for handle in repo_list:
|
||||
self.media_map[handle] = 1
|
||||
|
||||
def match_object(self,obj):
|
||||
if not obj:
|
||||
|
@ -32,7 +32,6 @@ from gettext import gettext as _
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Utils import get_source_referents
|
||||
from _Rule import Rule
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
76
src/Utils.py
76
src/Utils.py
@ -798,39 +798,34 @@ def get_source_referents(source_handle,db):
|
||||
secondary child-objects) to a given source handle in a given database.
|
||||
"""
|
||||
|
||||
# Persons
|
||||
person_list = [ handle \
|
||||
for handle in db.get_person_handles(sort_handles=False) \
|
||||
if db.get_person_from_handle(handle).has_source_reference(source_handle)
|
||||
]
|
||||
# Use one pass through the reference map to grab all the references
|
||||
object_list = [item for item in db.find_backlink_handles(source_handle)]
|
||||
|
||||
# Then form the object-specific lists
|
||||
|
||||
# Persons
|
||||
person_list = [item[1] for item in object_list if item[0] == 'Person']
|
||||
|
||||
# Families
|
||||
family_list = [ handle for handle in db.get_family_handles() \
|
||||
if db.get_family_from_handle(handle).has_source_reference(source_handle)
|
||||
]
|
||||
family_list = [item[1] for item in object_list if item[0] == 'Family']
|
||||
|
||||
# Events
|
||||
event_list = [ handle for handle in db.get_event_handles() \
|
||||
if db.get_event_from_handle(handle).has_source_reference(source_handle)
|
||||
]
|
||||
event_list = [item[1] for item in object_list if item[0] == 'Event']
|
||||
|
||||
# Places
|
||||
place_list = [ handle for handle in db.get_place_handles() \
|
||||
if db.get_place_from_handle(handle).has_source_reference(source_handle)
|
||||
]
|
||||
place_list = [item[1] for item in object_list if item[0] == 'Place']
|
||||
|
||||
# Sources
|
||||
source_list = [ handle for handle in db.get_source_handles() \
|
||||
if db.get_source_from_handle(handle).has_source_reference(source_handle)
|
||||
]
|
||||
source_list = [item[1] for item in object_list if item[0] == 'Source']
|
||||
|
||||
# Media Objects
|
||||
media_list = [ handle for handle in db.get_media_object_handles() \
|
||||
if db.get_object_from_handle(handle).has_source_reference(source_handle)
|
||||
]
|
||||
media_list = [item[1] for item in object_list if item[0] == 'MediaObject']
|
||||
|
||||
return (person_list,family_list,event_list,
|
||||
place_list,source_list,media_list)
|
||||
# Repositories
|
||||
repo_list = [item[1] for item in object_list if item[0] == 'Repository']
|
||||
|
||||
return (person_list,family_list,event_list,place_list,source_list,
|
||||
media_list,repo_list)
|
||||
|
||||
def get_media_referents(media_handle,db):
|
||||
"""
|
||||
@ -840,45 +835,28 @@ def get_media_referents(media_handle,db):
|
||||
to a given media handle in a given database.
|
||||
"""
|
||||
|
||||
# Use one pass through the reference map to grab all the references
|
||||
object_list = [item for item in db.find_backlink_handles(media_handle)]
|
||||
|
||||
# Then form the object-specific lists
|
||||
|
||||
# Persons
|
||||
person_list = [ handle \
|
||||
for handle in db.get_person_handles(sort_handles=False) \
|
||||
if media_handle in \
|
||||
[photo.get_reference_handle() for photo \
|
||||
in db.get_person_from_handle(handle).get_media_list()]
|
||||
]
|
||||
person_list = [item[1] for item in object_list if item[0] == 'Person']
|
||||
|
||||
# Families
|
||||
family_list = [ handle for handle in db.get_family_handles() \
|
||||
if media_handle in \
|
||||
[photo.get_reference_handle() for photo \
|
||||
in db.get_family_from_handle(handle).get_media_list()]
|
||||
]
|
||||
family_list = [item[1] for item in object_list if item[0] == 'Family']
|
||||
|
||||
# Events
|
||||
event_list = [ handle for handle in db.get_event_handles() \
|
||||
if media_handle in \
|
||||
[photo.get_reference_handle() for photo \
|
||||
in db.get_event_from_handle(handle).get_media_list()]
|
||||
]
|
||||
event_list = [ item[1] for item in object_list if item[0] == 'Event']
|
||||
|
||||
# Places
|
||||
place_list = [ handle for handle in db.get_place_handles() \
|
||||
if media_handle in \
|
||||
[photo.get_reference_handle() for photo \
|
||||
in db.get_place_from_handle(handle).get_media_list()]
|
||||
]
|
||||
place_list = [ item[1] for item in object_list if item[0] == 'Place']
|
||||
|
||||
# Sources
|
||||
source_list = [ handle for handle in db.get_source_handles() \
|
||||
if media_handle in \
|
||||
[photo.get_reference_handle() for photo \
|
||||
in db.get_source_from_handle(handle).get_media_list()]
|
||||
]
|
||||
source_list = [ item[1] for item in object_list if item[0] == 'Source']
|
||||
|
||||
return (person_list,family_list,event_list,place_list,source_list)
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user