def _build_dictionary(self, results):
        """
        Build model dictionary keyed by the relation's foreign key.

        :param results: The results
        :type results: Collection

        :rtype: dict
        """
        foreign = self._first_key

        dictionary = {}

        for result in results:
            key = getattr(result, foreign)
            if key not in dictionary:
                dictionary[key] = []

            dictionary[key].append(result)

        return dictionary
def _build_dictionary ( self , results ) : foreign = self . _first_key dictionary = { } for result in results : key = getattr ( result , foreign ) if key not in dictionary : dictionary [ key ] = [ ] dictionary [ key ] . append ( result ) return dictionary
Build model dictionary keyed by the relation's foreign key.

        :param results: The results
        :type results: Collection

        :rtype: dict