Esempio n. 1
0
    def get(self):
        """List contexts"""
        args = self.context_search_filter.parse_args()
        filters = {key: value for (key, value) in args.items() if
                   value is not None}

        entity_types = None

        if 'entity_types' in filters:
            etypes = []
            for etype in filters['entity_types']:
                try:
                    entity_type = db.const.EntityType(etype)
                    int(entity_type)
                    etypes.append(entity_type)
                except Errors.NotFoundError:
                    abort(404, message=u'Unknown entity type for '
                          'entity_types={}'.format(etype))
            entity_types = etypes or None

        es = EntitySpread(db.connection)
        contexts = es.list_spreads(entity_types=entity_types)
        return contexts