Пример #1
0
 def generate(vo):
     for did in list_dids_extended(scope=scope,
                                   filters=filters,
                                   type=type_param,
                                   limit=limit,
                                   long=long,
                                   recursive=recursive,
                                   vo=vo):
         yield dumps(did) + '\n'
Пример #2
0
    def GET(self, scope):
        """
        List all data identifiers in a scope which match a given metadata.

        HTTP Success:
            200 OK

        HTTP Error:
            401 Unauthorized
            404 KeyNotFound
            406 Not Acceptable
            409 UnsupportedOperation

        :param scope: The scope name.
        """

        header('Content-Type', 'application/x-json-stream')
        filters = {}
        limit = None
        long = False
        recursive = False
        if ctx.query:
            params = parse_qs(ctx.query[1:])
            for k, v in params.items():
                if k == 'type':
                    type = v[0]
                elif k == 'limit':
                    limit = v[0]
                elif k == 'long':
                    long = v[0] in ['True', '1']
                elif k == 'recursive':
                    recursive = v[0] == 'True'
                else:
                    filters[k] = v[0]

        try:
            for did in list_dids_extended(scope=scope,
                                          filters=filters,
                                          type=type,
                                          limit=limit,
                                          long=long,
                                          recursive=recursive,
                                          vo=ctx.env.get('vo')):
                yield dumps(did) + '\n'
        except UnsupportedOperation as error:
            raise generate_http_error(409, 'UnsupportedOperation',
                                      error.args[0])
        except KeyNotFound as error:
            raise generate_http_error(404, 'KeyNotFound', error.args[0])
        except Exception as error:
            print(format_exc())
            raise InternalError(error)