当前位置: 首页>>代码示例>>Python>>正文


Python Permission.description方法代码示例

本文整理汇总了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')
开发者ID:zpidreamteam,项目名称:ZPI,代码行数:33,代码来源:__init__.py

示例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":
开发者ID:Airead,项目名称:Flask-principal-example,代码行数:32,代码来源:FPrincipals.py


注:本文中的flask_principal.Permission.description方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。