genesis/genesis.py
def data(self, **query):
        """Query for Data object annotation."""
        objects = self.cache['objects']
        data = self.api.data.get(**query)['objects']
        data_objects = []

        for d in data:
            _id = d['id']
            if _id in objects:
                # Update existing object
                objects[_id].update(d)
            else:
                # Insert new object
                objects[_id] = GenData(d, self)

            data_objects.append(objects[_id])

        # Hydrate reference fields
        for d in data_objects:
            count += 1
            while True:
                ref_annotation = {}
                remove_annotation = []
                for path, ann in d.annotation.items():
                    if ann['type'].startswith('data:'):
                        # Referenced data object found
                        # Copy annotation
                        _id = ann['value']
                        if _id not in objects:
                            try:
                                d_tmp = self.api.data(_id).get()
                            except slumber.exceptions.HttpClientError as ex:
                                if ex.response.status_code == 404:
                                    continue
                                else:
                                    raise ex

                            objects[_id] = GenData(d_tmp, self)

                        annotation = objects[_id].annotation
                        ref_annotation.update({path + '.' + k: v for k, v in annotation.items()})
                        remove_annotation.append(path)
                if ref_annotation:
                    d.annotation.update(ref_annotation)
                    for path in remove_annotation:
                        del d.annotation[path]
                else:
                    break

        return data_objects
def data(self, **query):
        """Query for Data object annotation."""
        objects = self.cache['objects']
        data = self.api.data.get(**query)['objects']
        data_objects = []

        for d in data:
            _id = d['id']
            if _id in objects:
                # Update existing object
                objects[_id].update(d)
            else:
                # Insert new object
                objects[_id] = GenData(d, self)

            data_objects.append(objects[_id])

        # Hydrate reference fields
        for d in data_objects:
            count += 1
            while True:
                ref_annotation = {}
                remove_annotation = []
                for path, ann in d.annotation.items():
                    if ann['type'].startswith('data:'):
                        # Referenced data object found
                        # Copy annotation
                        _id = ann['value']
                        if _id not in objects:
                            try:
                                d_tmp = self.api.data(_id).get()
                            except slumber.exceptions.HttpClientError as ex:
                                if ex.response.status_code == 404:
                                    continue
                                else:
                                    raise ex

                            objects[_id] = GenData(d_tmp, self)

                        annotation = objects[_id].annotation
                        ref_annotation.update({path + '.' + k: v for k, v in annotation.items()})
                        remove_annotation.append(path)
                if ref_annotation:
                    d.annotation.update(ref_annotation)
                    for path in remove_annotation:
                        del d.annotation[path]
                else:
                    break

        return data_objects
Query for Data object annotation.