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

Update method raises an error when trying to make flask-session work with pymongo #137

Closed
caio2525 opened this issue Feb 23, 2022 · 5 comments

Comments

@caio2525
Copy link

Code example

from dotenv import load_dotenv
import os
from flask import Flask, session
from flask_session import Session
import pymongo

load_dotenv()

app = Flask(__name__)

MONGO_URI = os.environ.get("MONGO_URI")

client = pymongo.MongoClient(MONGO_URI)
neoDB = client.mydb

SESSION_TYPE = os.environ.get("SESSION_TYPE")
app.config['SECRET_KEY'] = 'mysecret'
app.config["SESSION_TYPE"] = SESSION_TYPE
app.config["SESSION_MONGODB"] = client
app.config["SESSION_MONGODB_DB"] = "mydb"
app.config["SESSION_MONGODB_COLLECT"] = "sessions"

sess = Session()
sess.init_app(app)

from User import routes

if __name__ == '__main__':
    app.run(host='127.0.0.1', port=5000, deb

Every time I try to access a route a get the following error:

File "/Documents/Portifólio/authSystem/env/lib/python3.8/site-packages/flask_session/sessions.py", line 456, in save_session self.store.update({'id': store_id}, File "/Documents/Portifólio/authSystem/env/lib/python3.8/site-packages/pymongo/collection.py", line 2584, in __call__ raise TypeError("'Collection' object is not callable. If you meant to " TypeError: 'Collection' object is not callable. If you meant to call the 'update' method on a 'Collection' object it is failing because no such method exists.

Somebody pointed out that it is due to the fact that update method was removed from pymongo.collection in version 4.0.

@vivCoding
Copy link

Someone made a PR for this earlier #135. We are just waiting for approval :(

@chushuai
Copy link

There are plans to support this function when? @vivCoding

@zedxos
Copy link

zedxos commented Sep 12, 2022

please when will this be updated

@jc-juarez
Copy link

Please accept the PR :(

@Lxstr
Copy link
Contributor

Lxstr commented Mar 10, 2024

Pymongo 4 now supported

@Lxstr Lxstr closed this as completed Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants