flask-session
flask-session copied to clipboard
Update method raises an error when trying to make flask-session work with pymongo
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.
Someone made a PR for this earlier https://github.com/fengsp/flask-session/pull/135. We are just waiting for approval :(
There are plans to support this function when? @vivCoding
please when will this be updated
Please accept the PR :(
Pymongo 4 now supported