def _get_relation_to_baseline( self ): context = aq_inner( self.context ) # get id intids = component.getUtility( IIntIds ) id = intids.getId( context ) # ask catalog catalog = component.getUtility( ICatalog ) relations = list(catalog.findRelations({ 'to_id' : id })) relations = filter( lambda r:r.from_attribute==STAGING_RELATION_NAME, relations ) # do we have a baseline in our relations? if relations and not len(relations) == 1: raise interfaces.CheckinException( "Baseline count mismatch" ) if not relations or not relations[0]: raise interfaces.CheckinException( "Baseline has disappeared" ) return relations[0]
def _getBaseline( self ): intids = component.getUtility( IIntIds ) relation = self._get_relation_to_baseline() if relation: baseline = intids.getObject( relation.from_id ) if not baseline: raise interfaces.CheckinException( "Baseline has disappeared" ) return baseline
def _get_relation_to_baseline(self): context = aq_inner(self.context) # get id intids = component.getUtility(IIntIds) id = intids.getId(context) # ask catalog catalog = component.getUtility(ICatalog) relations = catalog.findRelations({'to_id': id}) relations = [ i for i in relations if i.from_attribute == ITERATE_RELATION_NAME ] # do we have a baseline in our relations? if relations and not len(relations) == 1: raise interfaces.CheckinException('Baseline count mismatch') if not relations or not relations[0]: raise interfaces.CheckinException('Baseline has disappeared') return relations[0]