removed get_backlink_handles from RelLib
svn: r5592
This commit is contained in:
parent
dacc33610d
commit
1a102afbd1
@ -1,3 +1,7 @@
|
|||||||
|
2005-12-20 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
||||||
|
* src/RelLib/_helper.py: removed get_backlink_handles
|
||||||
|
* test/RelLib_Test.py: removed test for get_backlink_handles
|
||||||
|
|
||||||
2005-12-19 Don Allingham <don@gramps-project.org>
|
2005-12-19 Don Allingham <don@gramps-project.org>
|
||||||
* src/ReadXML.py: handle _NAME_TRANS keyerror exception
|
* src/ReadXML.py: handle _NAME_TRANS keyerror exception
|
||||||
|
|
||||||
|
@ -375,24 +375,6 @@ class PrimaryObject(BaseObject,PrivacyBase):
|
|||||||
|
|
||||||
def _replace_handle_reference(self,classname,old_handle,new_handle):
|
def _replace_handle_reference(self,classname,old_handle,new_handle):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_backlink_handles(self,db,include_classes=None):
|
|
||||||
"""Get a list of all primary objects that make some reference to this
|
|
||||||
primary object, either directly or via a child object.
|
|
||||||
|
|
||||||
Returns an iterator over tuples each of the form (class_name,handle).
|
|
||||||
|
|
||||||
To get a list use:
|
|
||||||
|
|
||||||
references = [ ref for ref in obj.get_backlink_handles() ]
|
|
||||||
|
|
||||||
@param db: a object with the find_backlink_handles method
|
|
||||||
@type db: usually a instance of a class derived from GrampsDbBase.
|
|
||||||
@param include_classes: the primary classes to include in the result.
|
|
||||||
@type: tuple of primary class names as strings, or None for all classes.
|
|
||||||
"""
|
|
||||||
|
|
||||||
return db.find_backlink_handles(self.get_handle(),include_classes)
|
|
||||||
|
|
||||||
def set_marker(self,marker):
|
def set_marker(self,marker):
|
||||||
self.marker = marker
|
self.marker = marker
|
||||||
|
@ -24,47 +24,8 @@ from GrampsDbTestBase import GrampsDbBaseTest
|
|||||||
class PrimaryObjectTest (GrampsDbBaseTest):
|
class PrimaryObjectTest (GrampsDbBaseTest):
|
||||||
"""Test methods on the PrimaryObject class"""
|
"""Test methods on the PrimaryObject class"""
|
||||||
|
|
||||||
def test_get_backlink_handles(self):
|
|
||||||
"""Check that backlink lookup works."""
|
|
||||||
|
|
||||||
source = self._add_source()
|
|
||||||
person = self._add_person_with_sources([source])
|
|
||||||
|
|
||||||
references = [ ref for ref in source.get_backlink_handles(self._db) ]
|
|
||||||
|
|
||||||
assert len(references) == 1
|
|
||||||
assert references[0] == (RelLib.Person.__name__,person.get_handle())
|
|
||||||
|
|
||||||
def test_get_backlink_handles_with_class_list(self):
|
|
||||||
"""Check backlink lookup with class list."""
|
|
||||||
|
|
||||||
source = self._add_source()
|
|
||||||
person = self._add_person_with_sources([source])
|
|
||||||
|
|
||||||
self._add_family_with_sources([source])
|
|
||||||
self._add_event_with_sources([source])
|
|
||||||
self._add_place_with_sources([source])
|
|
||||||
self._add_media_object_with_sources([source])
|
|
||||||
|
|
||||||
references = [ ref for ref in source.get_backlink_handles(self._db) ]
|
|
||||||
|
|
||||||
# make sure that we have the correct number of references (one for each object)
|
|
||||||
references = [ ref for ref in source.get_backlink_handles(self._db) ]
|
|
||||||
|
|
||||||
assert len(references) == 5, "len(references) == %s " % str(len(references))
|
|
||||||
|
|
||||||
# should just return the person reference
|
|
||||||
references = [ ref for ref in source.get_backlink_handles(self._db,(RelLib.Person.__name__,)) ]
|
|
||||||
assert len(references) == 1, "len(references) == %s " % str(len(references))
|
|
||||||
assert references[0][0] == RelLib.Person.__name__, "references = %s" % repr(references)
|
|
||||||
|
|
||||||
# should just return the person and event reference
|
|
||||||
references = [ ref for ref in source.get_backlink_handles(self._db,(RelLib.Person.__name__,
|
|
||||||
RelLib.Event.__name__)) ]
|
|
||||||
assert len(references) == 2, "len(references) == %s " % str(len(references))
|
|
||||||
assert references[0][0] == RelLib.Person.__name__, "references = %s" % repr(references)
|
|
||||||
assert references[1][0] == RelLib.Event.__name__, "references = %s" % repr(references)
|
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def testSuite():
|
def testSuite():
|
||||||
|
Loading…
Reference in New Issue
Block a user