eve-mongoengine
eve-mongoengine copied to clipboard
KeyError _etag
I am getting this exception with a simple code. It breaks the /person
endpoint and all of other endpoints I receive a 404 error.
Using:
-
eve 0.5.3 or in-dev
-
eve-Mongoengine 0.0.9
class Person(mongoengine.Document): name = mongoengine.StringField() age = mongoengine.IntField()
app = Eve() ext = EveMongoengine(app) ext.add_model(Person)
I had this issue until I changed some settings with the projection, at which point _etag existed. Collections without projection changes had this error, and those with projection changes didn't. Not sure what the underlying issue is but this fixes it.
from models import Person, Address
from eve_mongoengine import EveMongoengine
ext = EveMongoengine(app)
# Register model
ext.add_model([Person, Address])
# Remove password hash and salt from projections, this collection was error free
app.config['SOURCES']['person']['projection'] = {'salt': 0, 'password': 0}
# This next line removed the error, but you need to set all the fields
app.config['SOURCES']['address']['projection'] = {'street': 1, 'zipcode': 1, 'city': 1, 'state': 1}
- Eve 0.6.4
- MongoEngine 0.10.6
- Eve-Mongoengine 0.0.9
See also Eve issue #569.
Qualifying the offending code to read:
projection = [rev_map[field] for field in projection if field in rev_map]
gets past the problem, since the _etag is auto-generated if missing.
@seglberg any update on this?