I’m using MongoEngine in a flask 2.0.3 application. I want to overwrite the CRUD method in one MongoEngine model class. So I created a function to annotate the model class.
def customize(): def inner(cls): cls.delete = MethodCustomizer.delete(cls.delete) cls.modify = MethodCustomizer.modify(cls.modify) cls.reload = MethodCustomizer.reload(cls.reload) cls.save = MethodCustomizer.save(cls.save) cls.update = MethodCustomizer.update(cls.update) return cls return inner
@customize() class MwSection(Document): ...
This same model and class decorator work as expected in other applications such as stackstorm server, flask-restful (Flask==0.12.2, Flask-RESTful==0.3.6, flask-mongoengine==0.9.5), standalone python script; but not in flask 2.0.3 with flask-mongoengine==1.0.0.
As long as the model class is decorated, the docker container for the flask app will get into an endless restarting loop.