def findUpdateComponents(self): '''return a dictionary of components used in the updateToOne or updateToMany Methods.''' results = {} rels = Relationship.find(self, Contained=False) for rel in rels: if rel.components[0].id != self.id: component = rel.components[0] Type = rel.Type.split('-')[0] else: component = rel.components[1] Type = rel.Type.split('-')[1] if Type in results: results[Type].append(component) else: results[Type] = [component] imports = [] if '1' in results: imports.append('updateToOne') if 'M' in results: imports.append('updateToMany') if results: self.imports.append('from %s.utils import %s' % (self.zenpack.id, ",".join(sorted(imports)))) self.updateComponents = results
def custompaths(self): '''for non-contained child components return a dict {Type: component, parent component of the parent components} ''' custompaths = {} rels = Relationship.find(self, Contained=False, First=False) for rel in rels: for component in rel.components: if component == self: continue prel = Relationship.find(component, Contained=True, First=False) if prel: prel = prel[0] if not rel.Type in custompaths.keys(): custompaths[rel.Type] = [(component, prel.components[0])] return custompaths """obj = self.context.${first_component}()
def ManyRelationships(self): """return all of the ManyRelationships related to this component.""" rels = Relationship.find(self, First=True, Types=['1-M', 'M-M']) return rels
def relations(self): '''Find all the relationships that contain this component''' #return self.zenpack.relationshipLookup(self) return Relationship.find(self)