Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    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}()
Exemplo n.º 3
0
 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
Exemplo n.º 4
0
 def relations(self):
     '''Find all the relationships that contain this component'''
     #return self.zenpack.relationshipLookup(self)
     return Relationship.find(self)