예제 #1
0
    def relations(self, direction=D_ANCESTORS, flags=0):
        '''
        Return a list of cpl_relations
        '''
        vp = CPLDirect.new_std_vector_cpl_relation_tp()

        ret = CPLDirect.cpl_get_object_relations(self.id,
            direction, flags, CPLDirect.cpl_cb_collect_relation_vector, vp)
        if not CPLDirect.cpl_is_ok(ret):
            CPLDirect.delete_std_vector_cpl_relation_tp(vp)
            raise CPLException('Error retrieving relations: ' +
                    CPLDirect.cpl_error_string(ret), ret)

        v = CPLDirect.cpl_dereference_p_std_vector_cpl_relation_t(vp)
        l = []
        if direction == D_ANCESTORS:
            for entry in v:
                a = cpl_relation(entry.id, entry.other_object_id,
                    entry.query_object_id, entry.type, direction)
                l.append(a)
        else:
            for entry in v:
                a = cpl_relation(entry.id, entry.query_object_id,
                    entry.other_object_id, entry.type, direction)
                l.append(a)

        CPLDirect.delete_std_vector_cpl_relation_tp(vp)
        return l
예제 #2
0
    def relations(self, direction=D_ANCESTORS, flags=0):
        '''
        Return a list of cpl_relations
        '''
        vp = CPLDirect.new_std_vector_cpl_relation_tp()

        ret = CPLDirect.cpl_get_object_relations(self.id,
            direction, flags, CPLDirect.cpl_cb_collect_relation_vector, vp)
        if not CPLDirect.cpl_is_ok(ret):
            CPLDirect.delete_std_vector_cpl_relation_tp(vp)
            raise CPLException('Error retrieving relations: ' +
                    CPLDirect.cpl_error_string(ret), ret)

        v = CPLDirect.cpl_dereference_p_std_vector_cpl_relation_t(vp)
        l = []
        if direction == D_ANCESTORS:
            for entry in v:
                a = cpl_relation(entry.id, entry.other_object_id,
                    entry.query_object_id, entry.type, 
                    entry.bundle_id, direction)
                l.append(a)
        else:
            for entry in v:
                a = cpl_relation(entry.id, entry.query_object_id,
                    entry.other_object_id, entry.type, 
                    entry.bundle_id, direction)
                l.append(a)

        CPLDirect.delete_std_vector_cpl_relation_tp(vp)
        return l
예제 #3
0
    def get_bundle_relations(self, bundle):
        '''
        Return all relations in the specified bundle.
        '''
        vp = CPLDirect.new_std_vector_cpl_relation_tp()

        ret = CPLDirect.cpl_get_bundle_relations(bundle.id,
            CPLDirect.cpl_cb_collect_relation_vector, vp)
        if not CPLDirect.cpl_is_ok(ret):
            CPLDirect.delete_std_vector_cpl_relation_tp(vp)
            raise CPLException('Error retrieving relations: ' +
                    CPLDirect.cpl_error_string(ret), ret)

        v = CPLDirect.cpl_dereference_p_std_vector_cpl_relation_t(vp)
        l = []
        for entry in v:
            a = cpl_relation(entry.id, entry.query_object_id,
                entry.other_object_id, entry.type, D_DESCENDANTS)
            l.append(a)

        CPLDirect.delete_std_vector_cpl_relation_tp(vp)
        return l
예제 #4
0
    def get_bundle_relations(self, bundle):
        '''
        Return all relations in the specified bundle.
        '''
        vp = CPLDirect.new_std_vector_cpl_relation_tp()

        ret = CPLDirect.cpl_get_bundle_relations(bundle.id,
            CPLDirect.cpl_cb_collect_relation_vector, vp)
        if not CPLDirect.cpl_is_ok(ret):
            CPLDirect.delete_std_vector_cpl_relation_tp(vp)
            raise CPLException('Error retrieving relations: ' +
                    CPLDirect.cpl_error_string(ret), ret)

        v = CPLDirect.cpl_dereference_p_std_vector_cpl_relation_t(vp)
        l = []
        for entry in v:
            a = cpl_relation(entry.id, entry.query_object_id,
                entry.other_object_id, entry.type, 
                entry.bundle_id, D_DESCENDANTS)
            l.append(a)

        CPLDirect.delete_std_vector_cpl_relation_tp(vp)
        return l