def personRelations(ob,event): """ Item is modified - update links for children, spouse""" catalog = getUtility(ICatalog) intid = site.get_intids(ob) # get children. Make sure this ob is set as their parent # get parents. Make this this ob is set as their child # get spouse. Make sure this ob is set as their spouse ob.spouse.to_object.spouse = RelationValue(intid.getId(ob))
def parents(self): catalog = getUtility(ICatalog) intid = site.get_intids(self.context) parents = [] for u in sorted(catalog.findRelations({'to_id':intid.getId(self.context),'from_attribute':'children'})): u = u.from_object for p in u.members: p = p.to_object parents.append({'absolute_url':p.absolute_url(), 'title':p.Title(), 'born':p.born, 'died':p.died, }) return parents
def siblings(self): catalog = getUtility(ICatalog) intid = site.get_intids(self.context) siblings = [] for u in sorted(catalog.findRelations({'to_id':intid.getId(self.context),'from_attribute':'children'})): u = u.from_object for s in u.children: s = s.to_object if s.Title() != self.context.Title(): siblings.append({'absolute_url':s.absolute_url(), 'title':s.Title(), 'born':s.born, 'died':s.died, }) return siblings
def unions(self): _unions = [] catalog = getUtility(ICatalog) intid = site.get_intids(self.context) for u in sorted(catalog.findRelations({'to_id':intid.getId(self.context),'from_attribute':'members'})): _union = {} u = u.from_object _union['spouse'] = [i for i in u.members if i.to_object.title != self.context.title] if _union['spouse']: _union['spouse'] = _union['spouse'][0] children = [] for c in u.children: child = c.to_object children.append({'absolute_url':child.absolute_url(), 'title':child.Title(), 'born':child.born, 'died':child.died, }) _union['children'] = children _unions.append(_union) return _unions