Ted Xu
Ted Xu

Reputation: 1093

Flask Flask-Security with GAE ndb?

I am building and hosting my application on the Google App Engine with Python on Flask. And now I want to use the flask-security extension and realized there isn't much resources to start with under my configuration, which is a bit surprise to me as I thought this stack should be quick common.

On the Flask-Security's Quick Start Page, examples of SQLAlchemy, MongoDB and Peewee are provided. However, I cannot find samples of GAE-NDB in particular. If someone can point me out if it is possible to use flask-security on my dev stack, and it would be much appreciated if some examples of how to create security object like below sample code in SQLAlchemy

db = SQLAlchemy(app)
class User(db.Model, UserMixin):
    pass

# Setup Flask-Security
user_datastore = SQLAlchemyUserDatastore(db, User)
security = Security(app, user_datastore)

Thank you very much!

UPDATE and my workaround for those of you who have the same question or doubts

GAE-NDB is not compatible, at least you have to do some extra work, with flask-security. Below is the from flask-security homepage

Additionally, it assumes you’ll be using a common library for your database connections and model definitions. Flask-Security supports the following Flask extensions out of the box for data persistence:

  • Flask-SQLAlchemy
  • Flask-MongoEngine
  • Flask-Peewee

and my final solution is to use mongodb as my datastore, which is hosted on mongolab. They have free instance for prototyping and development.

Upvotes: 4

Views: 1305

Answers (1)

topless
topless

Reputation: 8221

You can get a good idea from gae-init., it is a complete implementation of a web application based on Flask and Google App Engine. Following the documentation and digging a bit in the code will give you a good idea about how things are setup along with lots of good practices and common functionality that every web app requires.

Upvotes: 3

Related Questions