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

Error when update or delete an item #85

Open
itsjef opened this issue Feb 13, 2019 · 0 comments
Open

Error when update or delete an item #85

itsjef opened this issue Feb 13, 2019 · 0 comments

Comments

@itsjef
Copy link

itsjef commented Feb 13, 2019

Update: Problem with DELETE resolved after dowgrading to Eve 0.7.10 where common.get_document() still passed only 3 arguments to app.data.find_one() but still persist with PUT/PATCH.


In my simple app, I can create and get new items just fine but when I tried a PATCH/PUT/DELETE request then I got the error:

TypeError: find_one() takes 3 positional arguments but 5 were given

The error doesn't appear when Mongodb is used instead of Elasticsearch.

My following setup and code:

  • Python version: 3.6
  • Elasticsearch version: 2.4.6
  • Eve version: 0.8.1
  • Eve-Elastic version: 2.5.0

Source code

# settings.py
import os

ELASTICSEARCH_URL = os.environ.get("ELASTICSEARCH_URL", "http://localhost:9200")
ELASTICSEARCH_INDEX = os.environ.get("ELASTICSEARCH_INDEX", "eve")

RESOURCE_METHODS = ["GET", "POST"]
ITEM_METHODS = ["GET", "PATCH", "PUT", "DELETE"]

DOMAIN = {
    "test": {
        "schema": {"foo": {"type": "string"}},
        "item_url": 'regex("[\w,.:_-]+")',
        "datasource": {"backend": "elastic"},
    },
}

# run.py
from eve import Eve
from eve_elastic import Elastic

if __name__ == "__main__":
    Eve(data=Elastic).run()

API Call

curl -X DELETE \
  http://localhost:5000/test/AWjlAAzY-Wkn3SL9OgCa \
  -H 'If-Match: 16e79eb4b035c2d25b08f5bb46eeadd8002e4230' 

Traceback

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/eve/flaskapp.py", line 1105, in __call__
    return super(Eve, self).__call__(environ, start_response)
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2309, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2295, in wsgi_app
    response = self.handle_exception(e)
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1741, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.6/site-packages/eve/endpoints.py", line 100, in item_endpoint
    response = deleteitem(resource, **lookup)
  File "/usr/local/lib/python3.6/site-packages/eve/methods/common.py", line 317, in rate_limited
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/eve/auth.py", line 80, in decorated
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/eve/methods/common.py", line 1251, in decorated
    r = f(resource, **combined_args)
  File "/usr/local/lib/python3.6/site-packages/eve/methods/delete.py", line 46, in deleteitem
    return deleteitem_internal(resource, concurrency_check=True, **lookup)
  File "/usr/local/lib/python3.6/site-packages/eve/methods/delete.py", line 97, in deleteitem_internal
    original = get_document(resource, concurrency_check, original, **lookup)
  File "/usr/local/lib/python3.6/site-packages/eve/methods/common.py", line 88, in get_document
    resource, req, check_auth_value, force_auth_field_projection, **lookup
TypeError: find_one() takes 3 positional arguments but 5 were given
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

1 participant