pallets-eco / flask-session

Server side session extension for Flask
https://flask-session.readthedocs.io
BSD 3-Clause "New" or "Revised" License
501 stars 239 forks source link

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

Closed caio2525 closed 6 months ago

caio2525 commented 2 years ago

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 commented 2 years ago

Someone made a PR for this earlier https://github.com/fengsp/flask-session/pull/135. We are just waiting for approval :(

chushuai commented 2 years ago

There are plans to support this function when? @vivCoding

zedxos commented 2 years ago

please when will this be updated

jc-juarez commented 1 year ago

Please accept the PR :(

Lxstr commented 6 months ago

Pymongo 4 now supported