@@ -0,0 +1,1322 @@
+# -*- coding: utf-8 -*-%0Afrom collections import namedtuple%0Afrom flask import Flask, g, render_template, abort%0Afrom flask_sqlalchemy import SQLAlchemy%0Afrom flask_perm import Perm%0A%0Aapp = Flask(__name__)%0Adb = SQLAlchemy()%0Aperm = Perm()%0Aapp.config%5B'DEBUG'%5D = True%0Aapp.config%5B'SECRET_KEY'%5D = 'secret key'%0Aapp.config%5B'SQLALCHEMY_DATABASE_URI'%5D = 'sqlite:////tmp/flask_perm.db'%0Aapp.config%5B'PERM_ADMIN_USERNAME'%5D = 'admin'%0Aapp.config%5B'PERM_ADMIN_PASSWORD'%5D = 'test'%0Aapp.config%5B'PERM_SUPER_ADMIN_USER_IDS'%5D = %5B1%5D%0A%0Adb.app = app%0Adb.init_app(app)%0Aperm.app = app%0Aperm.init_app(app)%0A%0Aclass User(namedtuple('User', 'id nickname')):%0A    pass%0A%0A@app.before_request%0Adef before_request():%0A    g.user = User(**%7B'id': 1, 'nickname': 'user1'%7D)%0A%0A@perm.user_loader%0Adef load_user(user_id):%0A    return User(**%7B'id': user_id, 'nickname': 'user%25d' %25 user_id%7D)%0A%0A@perm.users_loader%0Adef load_users(filter_by, sort_field, sort_dir, offset, limit):%0A    return %5BUser(**%7B'id': id, 'nickname': 'user%25d' %25 id%7D) for id in range(20)%5D%0A%0A@perm.current_user_loader%0Adef load_current_user():%0A    return g.user%0A%0A@app.errorhandler(perm.Denied)%0Adef permission_denied(e):%0A    return 'FORBIDDEN', 403%0A%0A@app.route('/post/publish')%0A@perm.require_permission('post.publish')%0Adef publish_post():%0A    return 'Hey, you can publish post!'%0A%0Aif __name__ == '__main__':%0A    app.run()%0A

Add example.py