Пример #1
0
    def put(self, request: Request):
        # TODO(dcramer): this should validate options before saving them
        for k, v in request.data.items():
            if v and isinstance(v, str):
                v = v.strip()
            try:
                option = options.lookup_key(k)
            except options.UnknownOption:
                # TODO(dcramer): unify API errors
                return Response(
                    {"error": "unknown_option", "errorDetail": {"option": k}}, status=400
                )

            try:
                if not (option.flags & options.FLAG_ALLOW_EMPTY) and not v:
                    options.delete(k)
                else:
                    options.set(k, v)
            except (TypeError, AssertionError) as e:
                # TODO(chadwhitacre): Use a custom exception for the
                # immutability case, especially since asserts disappear with
                # `python -O`.
                return Response(
                    {
                        "error": "invalid_type" if type(e) is TypeError else "immutable_option",
                        "errorDetail": {"option": k, "message": str(e)},
                    },
                    status=400,
                )
        # TODO(dcramer): this has nothing to do with configuring options and
        # should not be set here
        options.set("sentry:version-configured", sentry.get_version())
        return Response(status=200)
Пример #2
0
 def put(self, request):
     # TODO(dcramer): this should validate options before saving them
     for k, v in request.DATA.iteritems():
         if v and isinstance(v, basestring):
             v = v.strip()
         try:
             if not v:
                 options.delete(k)
             else:
                 options.set(k, v)
         except options.UnknownOption:
             # TODO(dcramer): unify API errors
             return Response({
                 'error': 'unknown_option',
                 'errorDetail': {
                     'option': k,
                 },
             }, status=400)
         except TypeError as e:
             return Response({
                 'error': 'invalid_type',
                 'errorDetail': {
                     'option': k,
                     'message': unicode(e),
                 },
             }, status=400)
     # TODO(dcramer): this has nothing to do with configuring options and
     # should not be set here
     options.set('sentry:version-configured', sentry.get_version())
     return Response(status=200)
Пример #3
0
    def put(self, request):
        # TODO(dcramer): this should validate options before saving them
        for k, v in six.iteritems(request.DATA):
            if v and isinstance(v, six.string_types):
                v = v.strip()
            try:
                option = options.lookup_key(k)
            except options.UnknownOption:
                # TODO(dcramer): unify API errors
                return Response({
                    'error': 'unknown_option',
                    'errorDetail': {
                        'option': k,
                    },
                }, status=400)

            try:
                if not (option.flags & options.FLAG_ALLOW_EMPTY) and not v:
                    options.delete(k)
                else:
                    options.set(k, v)
            except TypeError as e:
                return Response({
                    'error': 'invalid_type',
                    'errorDetail': {
                        'option': k,
                        'message': six.text_type(e),
                    },
                }, status=400)
        # TODO(dcramer): this has nothing to do with configuring options and
        # should not be set here
        options.set('sentry:version-configured', sentry.get_version())
        return Response(status=200)
Пример #4
0
    def put(self, request):
        # TODO(dcramer): this should validate options before saving them
        for k, v in request.DATA.iteritems():
            if v and isinstance(v, basestring):
                v = v.strip()
            try:
                option = options.lookup_key(k)
            except options.UnknownOption:
                # TODO(dcramer): unify API errors
                return Response({
                    'error': 'unknown_option',
                    'errorDetail': {
                        'option': k,
                    },
                }, status=400)

            try:
                if not (option.flags & options.FLAG_ALLOW_EMPTY) and not v:
                    options.delete(k)
                else:
                    options.set(k, v)
            except TypeError as e:
                return Response({
                    'error': 'invalid_type',
                    'errorDetail': {
                        'option': k,
                        'message': unicode(e),
                    },
                }, status=400)
        # TODO(dcramer): this has nothing to do with configuring options and
        # should not be set here
        options.set('sentry:version-configured', sentry.get_version())
        return Response(status=200)
Пример #5
0
def delete(option, no_input):
    "Delete/unset a configuration option."
    from sentry import options
    from sentry.options.manager import UnknownOption
    if not no_input:
        click.confirm('Are you sure you want to delete "%s"?' % option, default=False, abort=True)
    try:
        options.delete(option)
    except UnknownOption:
        raise click.ClickException('unknown option: %s' % option)
Пример #6
0
def delete(option, no_input):
    "Delete/unset a configuration option."
    from sentry import options
    from sentry.options.manager import UnknownOption
    if not no_input:
        click.confirm('Are you sure you want to delete "%s"?' % option, default=False, abort=True)
    try:
        options.delete(option)
    except UnknownOption:
        raise click.ClickException('unknown option: %s' % option)
Пример #7
0
    def put(self, request):
        # TODO(dcramer): this should validate options before saving them
        for k, v in six.iteritems(request.data):
            if v and isinstance(v, six.string_types):
                v = v.strip()
            try:
                option = options.lookup_key(k)
            except options.UnknownOption:
                # TODO(dcramer): unify API errors
                return Response(
                    {
                        "error": "unknown_option",
                        "errorDetail": {
                            "option": k
                        }
                    },
                    status=400)

            try:
                if not (option.flags & options.FLAG_ALLOW_EMPTY) and not v:
                    options.delete(k)
                else:
                    options.set(k, v)
            except TypeError as e:
                return Response(
                    {
                        "error": "invalid_type",
                        "errorDetail": {
                            "option": k,
                            "message": six.text_type(e)
                        },
                    },
                    status=400,
                )
        # TODO(dcramer): this has nothing to do with configuring options and
        # should not be set here
        options.set("sentry:version-configured", sentry.get_version())
        return Response(status=200)
Пример #8
0
 def _restore_upload_url_options(self):
     options.delete("system.upload-url-prefix")