Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ivanyu/flask-mongo-sessions
Server-side sessions for Flask with MongoDB
https://github.com/ivanyu/flask-mongo-sessions
flask mongodb
Last synced: 2 months ago
JSON representation
Server-side sessions for Flask with MongoDB
- Host: GitHub
- URL: https://github.com/ivanyu/flask-mongo-sessions
- Owner: ivanyu
- License: mit
- Created: 2013-03-23T21:35:09.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2020-07-20T08:30:00.000Z (over 4 years ago)
- Last Synced: 2024-03-27T04:23:55.367Z (10 months ago)
- Topics: flask, mongodb
- Language: Python
- Size: 29.3 KB
- Stars: 8
- Watchers: 3
- Forks: 6
- Open Issues: 7
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES
- License: LICENSE
Awesome Lists containing this project
README
flask-mongo-sessions
====================.. module:: flask-mongo-sessions
flask-mongo-sessions helps you to add server-side sessions to `Flask`_ with
`MongoDB`_ storage.⚠️ This project is not being actively developed by the original author any more. PRs are welcome, though.
⚠️ Please note that Python 3 is not supported now (`issue `_).
Requirements
------------The extensions requires Flask>=0.8 and also `PyMongo`_ (`Flask-PyMongo`_)
or `MongoEngine`_ (`Flask-MongoEngine`_)Tested with Python 2.5, 2.6 and 2.7.
Installation
------------Installation of the extension is easy::
$ pip install flask-mongo-sessions
or::
$ easy_install install flask-mongo-sessions
or::
$ python setup.py install
Usage
-----To work, the extension needs PyMongo's *Database* object and sessions
collection name. The object can be taken from PyMongo:.. code-block:: python
from flask import Flask
from flask.ext.pymongo import PyMongo
from flask.ext.mongo_sessions import MongoDBSessionInterfaceapp = Flask(__name__)
app.config['MONGO_DBNAME'] = 'database-name'
mongo = PyMongo(app)
with app.app_context():
app.session_interface = MongoDBSessionInterface(app, mongo.db, 'sessions')or from MongoEngine:
.. code-block:: python
from flask import Flask
from flask.ext.mongoengine import MongoEngine
from flask.ext.mongo_sessions import MongoDBSessionInterfaceapp = Flask(__name__)
app.config['MONGODB_DB'] = 'database-name'
db = mongo.connection[app.config['MONGODB_DB']]
app.session_interface = MongoDBSessionInterface(app, db, 'sessions')All connection parameters (address, port, etc.) must be set for the respective
extension.Users sessions will be stored in the specified MongoDB database in
the collection with specified name.Authors and contributors
------------------------
Originally developed by Ivan Yurchenko.License
-------
MIT license (see *LICENSE* file)Also
----Please, send me a feedback about the app (bugs, examples of usage etc.)
.. _Flask: http://flask.pocoo.org/
.. _MongoDB: http://www.mongodb.org/
.. _PyMongo: https://github.com/mongodb/mongo-python-driver
.. _Flask-PyMongo: https://github.com/dcrosta/flask-pymongo/
.. _MongoEngine: http://mongoengine.org/
.. _Flask-MongoEngine: https://github.com/MongoEngine/flask-mongoengine