I have created a Python application using Flask-Stormpath and am following the documentation to create groups for authentication. Prior to adding the 5 lines of group creation code the program runs perfectly. Now when I compile the following code (showing just the first part of app.py in this case):
from os import environ
from flask import Flask, session, request, jsonify, g, abort, url_for, redirect, render_template, g, flash, escape
from flask_cors import CORS, cross_origin
from flask_stormpath import StormpathManager, User, login_required, login_user, logout_user, user, groups_required
from stormpath.error import Error as StormpathError
from datetime import timedelta
app = Flask(__name__, static_url_path='/static')
CORS(app)
app.config['DEBUG'] = True
app.config['SECRET_KEY'] = environ.get('SECRET_KEY', 'this_should_be_configured')
app.config['STORMPATH_API_KEY_ID'] = environ.get('STORMPATH_API_KEY_ID')
app.config['STORMPATH_API_KEY_SECRET'] = environ.get('STORMPATH_API_KEY_SECRET')
app.config['STORMPATH_APPLICATION'] = environ.get('STORMPATH_APPLICATION')
app.config['STORMPATH_APPLICATION_HREF'] = environ.get('STORMPATH_APPLICATION_HREF')
app.config['STORMPATH_CLIENT_APIKEY_ID'] = environ.get('STORMPATH_CLIENT_APIKEY_ID')
app.config['STORMPATH_CLIENT_APIKEY_SECRET'] = environ.get('STORMPATH_CLIENT_APIKEY_SECRET')
app.config['STORMPATH_URL'] = environ.get('STORMPATH_URL')
app.config['STORMPATH_ENABLE_LOGIN'] = False
app.config['STORMPATH_ENABLE_REGISTRATION'] = False
app.config['STORMPATH_ENABLE_LOGOUT'] = False
app.config['STORMPATH_COOKIE_DURATION'] = timedelta(minutes=60)
stormpath_manager = StormpathManager(app)
stormpath_manager.login_view = '.login'
# Code to add groups to the application
directory = stormpath_manager.application.default_account_store_mapping.account_store
guests = directory.groups.create({'name': 'guests'})
members = directory.groups.create({'name': 'members'})
managers = directory.groups.create({'name': 'managers'})
admins = directory.groups.create({'name': 'admins'})
I now get a compilation error from within the Stormpath library:
(venv) Marks-MacBook-Pro-2:flask_heroku markschulz$ python app.py Traceback (most recent call last): File "app.py", line 41, in directory = stormpath_manager.application.default_account_store_mapping.account_store File "/Users/markschulz/Projects/maid2match/venv/lib/python2.7/site-packages/flask_stormpath/init.py", line 266, in application ctx = stack.top.app AttributeError: 'NoneType' object has no attribute 'app'
What do I need to do to get past this error? The code line for 'directory' is taken directly from the Stormpath documentation.