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

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

Open
jwag956 opened this issue Aug 18, 2022 · 1 comment
Open

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

jwag956 opened this issue Aug 18, 2022 · 1 comment
Labels
type: bug Something isn't working

Comments

@jwag956
Copy link

jwag956 commented Aug 18, 2022

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 insspb added the type: bug Something isn't working label Aug 18, 2022
@insspb
Copy link
Collaborator

insspb commented Aug 18, 2022

@jwag956
Thanks
Hmmm. Interesting how I passes tests )

efrederickson added a commit to efrederickson/flask-mongoengine that referenced this issue Oct 21, 2022
Apply the fix suggested in MongoEngine#512
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants