Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to delete entries #78

Closed
rule88 opened this issue Sep 29, 2020 · 5 comments
Closed

Unable to delete entries #78

rule88 opened this issue Sep 29, 2020 · 5 comments

Comments

@rule88
Copy link

rule88 commented Sep 29, 2020

currently developing an API, which all seems to work ok using safrs. However, deleting entries somehow don't seem possible, the following stacktrace is printed:

[2020-09-29 11:20:06,951] ERROR: 'dict' object is not callable
The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a dict.
Traceback (most recent call last):
  File "/venv/lib/python3.8/site-packages/flask/app.py", line 1974, in make_response
    rv = self.response_class.force_type(rv, request.environ)
  File "/venv/lib/python3.8/site-packages/werkzeug/wrappers.py", line 921, in force_type
    response = BaseResponse(*_run_wsgi_app(response, environ))
  File "/venv/lib/python3.8/site-packages/werkzeug/test.py", line 923, in run_wsgi_app
    app_rv = app(environ, start_response)
TypeError: 'dict' object is not callable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/venv/lib/python3.8/site-packages/safrs/safrs_api.py", line 538, in method_wrapper
    result = fun(*args, **kwargs)
  File "/venv/lib/python3.8/site-packages/safrs/jsonapi.py", line 495, in delete
    return make_response({}, HTTPStatus.NO_CONTENT)
  File "/venv/lib/python3.8/site-packages/safrs/jsonapi.py", line 38, in make_response
    response = flask_make_response(*args, **kwargs)
  File "/venv/lib/python3.8/site-packages/flask/helpers.py", line 213, in make_response
    return current_app.make_response(args)
  File "/venv/lib/python3.8/site-packages/flask/app.py", line 1982, in make_response
    reraise(TypeError, new_error, sys.exc_info()[2])
  File "/venv/lib/python3.8/site-packages/flask/_compat.py", line 34, in reraise
    raise value.with_traceback(tb)
  File "/venv/lib/python3.8/site-packages/flask/app.py", line 1974, in make_response
    rv = self.response_class.force_type(rv, request.environ)
  File "/venv/lib/python3.8/site-packages/werkzeug/wrappers.py", line 921, in force_type
    response = BaseResponse(*_run_wsgi_app(response, environ))
  File "/venv/lib/python3.8/site-packages/werkzeug/test.py", line 923, in run_wsgi_app
    app_rv = app(environ, start_response)
TypeError: 'dict' object is not callable
The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a dict.
[2020-09-29 11:20:06,952] ERROR: 'dict' object is not callable
The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a dict.
[2020-09-29 11:20:06,952] ERROR in app: Exception on /user/1/ [DELETE]
Traceback (most recent call last):
  File "/venv/lib/python3.8/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/venv/lib/python3.8/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/venv/lib/python3.8/site-packages/flask_restful/__init__.py", line 468, in wrapper
    resp = resource(*args, **kwargs)
  File "/venv/lib/python3.8/site-packages/flask_restful_swagger_2/__init__.py", line 39, in decorator
    return f(*args, **kwargs)
  File "/venv/lib/python3.8/site-packages/flask/views.py", line 88, in view
    return self.dispatch_request(*args, **kwargs)
  File "/venv/lib/python3.8/site-packages/flask_restful/__init__.py", line 583, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/venv/lib/python3.8/site-packages/flask_restful_swagger_2/swagger.py", line 219, in inner
    return f(self, *args, **kwargs)
  File "/venv/lib/python3.8/site-packages/safrs/safrs_api.py", line 566, in method_wrapper
    abort(status_code, errors=[errors])
  File "/venv/lib/python3.8/site-packages/flask_restful/__init__.py", line 32, in abort
    original_flask_abort(http_status_code)
  File "/venv/lib/python3.8/site-packages/werkzeug/exceptions.py", line 707, in abort
    return _aborter(status, *args, **kwargs)
  File "/venv/lib/python3.8/site-packages/werkzeug/exceptions.py", line 687, in __call__
    raise self.mapping[code](*args, **kwargs)
werkzeug.exceptions.InternalServerError: 500 Internal Server Error: The server encountered an internal error and was unable to complete your request.  Either the server is overloaded or there is an error in the application.
127.0.0.1 - - [29/Sep/2020 11:20:06] "DELETE /user/1/ HTTP/1.1" 500

I am using a MySQL database:

mysql> describe user;
+-------+-------------+------+-----+---------+----------------+
| Field | Type        | Null | Key | Default | Extra          |
+-------+-------------+------+-----+---------+----------------+
| id    | int         | NO   | PRI | NULL    | auto_increment |
| name    | varchar(45) | YES  | UNI | NULL    |                |
+-------+-------------+------+-----+---------+----------------+
mysql> select * from user;
+----+------+
| id | ip   |
+----+------+
|  1 | test |
+----+------+

and the following model:

class BaseModel(SAFRSBase, db.Model):
    __abstract__ = True

class User(BaseModel):
    """
        description: User description
    """
    __tablename__ = "user"

    id = db.Column(db.Integer, primary_key=True, unique=True, nullable=False)
    name = db.Column(db.String(45), unique=True)

Hope you can help me with this as safrs is a real nice way in producing a self documenting API.

@thomaxxl
Copy link
Owner

Hi,

This seems to be related to python3.8. Can you try with python3.6 ?
I'll fix this asap.

@thomaxxl
Copy link
Owner

Can you try with the latest commit for 3.8?
I'll have to test this some more though.

@rule88
Copy link
Author

rule88 commented Sep 30, 2020

Hi @thomaxxl I can confirm that it does work with 3.6, will now try with latest commit on 3.8.

@rule88
Copy link
Author

rule88 commented Sep 30, 2020

Hi @thomaxxl I now also can confirm that delete operation do work on python 3.8. Thanks for your support !

@thomaxxl
Copy link
Owner

thomaxxl commented Oct 4, 2020

v2.10.2

@thomaxxl thomaxxl closed this as completed Oct 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants