本文整理汇总了Python中flask_principal.Permission.description方法的典型用法代码示例。如果您正苦于以下问题:Python Permission.description方法的具体用法?Python Permission.description怎么用?Python Permission.description使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask_principal.Permission
的用法示例。
在下文中一共展示了Permission.description方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SQLAlchemy
# 需要导入模块: from flask_principal import Permission [as 别名]
# 或者: from flask_principal.Permission import description [as 别名]
db = SQLAlchemy(app)
# login manager
lm = LoginManager()
lm.init_app(app)
lm.login_view = 'login'
principals = Principal(app, skip_static=True)
#Needs
be_admin = RoleNeed('admin')
be_user = RoleNeed('user')
#Permissions
admin_permission = Permission(be_admin)
admin_permission.description = "Admin's permissions"
user_perrmission = Permission(be_user)
user_perrmission.description = "User's permissions"
apps_needs = [be_admin, be_user]
apps_permissions = [admin_permission, user_perrmission]
# mail
app.config.update(
DEBUG=False,
#EMAIL SETTINGS
MAIL_SERVER='smtp.gmail.com',
MAIL_PORT=465,
MAIL_USE_SSL=True,
MAIL_USERNAME = '[email protected]',
MAIL_PASSWORD = 'ZPIdream')
示例2: Principal
# 需要导入模块: from flask_principal import Permission [as 别名]
# 或者: from flask_principal.Permission import description [as 别名]
app.config.update(
DEBUG=True,
SECRET_KEY='secret_xxx')
principals = Principal(app, skip_static=True)
# Needs
be_admin = RoleNeed('admin')
be_editor = RoleNeed('editor')
to_sign_in = ActionNeed('sign in')
# Permissions
user = Permission(to_sign_in)
user.description = "User's permissions"
editor = Permission(be_editor)
editor.description = "Editor's permissions"
admin = Permission(be_admin)
admin.description = "Admin's permissions"
apps_needs = [be_admin, be_editor, to_sign_in]
apps_permissions = [user, editor, admin]
def authenticate(email, password):
if password == email + "user":
return "the_only_user"
elif password == email + "admin":
return "the_only_admin"
elif password == email + "editor":