def check_relations(self, relations):
        """Recursive function which checks if a relation is valid."""
        for rel in relations:
            if not rel:
                continue
            fields = rel.split('.', 1)

            local_field = fields[0]
            if local_field not in self.fields:
                raise ValueError('Unknown field "{}"'.format(local_field))

            field = self.fields[local_field]
            if not isinstance(field, BaseRelationship):
                raise ValueError('Can only include relationships. "{}" is a "{}"'
                                 .format(field.name, field.__class__.__name__))

            field.include_data = True
            if len(fields) > 1:
                field.schema.check_relations(fields[1:])
def check_relations ( self , relations ) : for rel in relations : if not rel : continue fields = rel . split ( '.' , 1 ) local_field = fields [ 0 ] if local_field not in self . fields : raise ValueError ( 'Unknown field "{}"' . format ( local_field ) ) field = self . fields [ local_field ] if not isinstance ( field , BaseRelationship ) : raise ValueError ( 'Can only include relationships. "{}" is a "{}"' . format ( field . name , field . __class__ . __name__ ) ) field . include_data = True if len ( fields ) > 1 : field . schema . check_relations ( fields [ 1 : ] )
Recursive function which checks if a relation is valid.