MongoEngine / flask-mongoengine

MongoEngine flask extension with WTF model forms support
Other
840 stars 256 forks source link

New JSONProvider use of super() not quite right #512

Open jwag956 opened 2 years ago

jwag956 commented 2 years ago

I am implementing similar logic in Flask-Security - so stole some code :-)

The code:

class MongoEngineJSONProvider(superclass):
        """A JSON Provider update for Flask 2.2.0+"""

        @staticmethod
        def default(obj):
            """Extend JSONProvider default static method, with Mongo objects."""
            if isinstance(
                obj,
                (BaseDocument, QuerySet, CommandCursor, DBRef, ObjectId),
            ):
                return _convert_mongo_objects(obj)
            return super().default(obj)

I don't think is quite right - using super() for static methods doesn't work - you need to do something like: return super(MongoEngineJSONProvider, MongoEngineJSONProvider).default(obj)

insspb commented 2 years ago

@jwag956 Thanks Hmmm. Interesting how I passes tests )