def _aliasTarget(self, value): if '_aliasTarget' in self.__dict__: raise AttributeError("Cannot set _aliasTarget more than once") if not IRelationValue.providedBy(value): raise AttributeError("_aliasTarget must be an IRelationValue") counter = 0 target = value.to_object while IAlias.providedBy( target) and counter < 1000: # avoid infinite loop target = aq_inner(target._target) counter += 1 if counter > 0: intids = queryUtility(IIntIds) if intids is None: raise LookupError("Cannot find intid utility") to_id = intids.getId(target) value = RelationValue(to_id) self.__dict__['_aliasTarget'] = value
def _aliasTarget(self, value): if '_aliasTarget' in self.__dict__: raise AttributeError("Cannot set _aliasTarget more than once") if not IRelationValue.providedBy(value): raise AttributeError("_aliasTarget must be an IRelationValue") counter = 0 target = value.to_object while IAlias.providedBy(target) and counter < 1000: # avoid infinite loop target = aq_inner(target._target) counter += 1 if counter > 0: intids = queryUtility(IIntIds) if intids is None: raise LookupError("Cannot find intid utility") to_id = intids.getId(target) value = RelationValue(to_id) self.__dict__['_aliasTarget'] = value
def test_alias_interfaces(self): self.failUnless(IATDocument.providedBy(self.folder['a1'])) self.failUnless(IAlias.providedBy(self.folder['a1'])) self.failIf(IAlias.providedBy(self.folder['d1']))