本文整理汇总了Python中main.PageData.errortext方法的典型用法代码示例。如果您正苦于以下问题:Python PageData.errortext方法的具体用法?Python PageData.errortext怎么用?Python PageData.errortext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类main.PageData
的用法示例。
在下文中一共展示了PageData.errortext方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: admin_set_accesslevel
# 需要导入模块: from main import PageData [as 别名]
# 或者: from main.PageData import errortext [as 别名]
def admin_set_accesslevel(user, level):
"""
:URL: /admin/users/<user>/accesslevel/<level>
Change a user's access level. The user requesting the access level change must be more privileged
than the level they are setting.
Redirects back if there was an error, otherwise redirects to the user's profile.
"""
pd = PageData()
if pd.authuser.accesslevel != 255 and pd.authuser.accesslevel <= int(level):
app.logger.error('Accesslevel change was denied for user: ' + pd.authuser.username)
flash("Access level change denied.")
return redirect_back('index')
try:
moduser = SiteUser.create(user)
if pd.authuser.accesslevel != 255 and moduser.accesslevel >= pd.authuser.accesslevel:
flash("Please contact an admin to modify this user's account.")
return redirect_back('index')
except NoUser:
app.logger.error('Accesslevel change attempted for invalid user by: ' + pd.authuser.username)
pd.title = "User does not exist"
pd.errortext = "The user does not exist"
return render_template('error.html', pd=pd)
moduser.newaccesslevel(level)
flash('User ' + user + '\'s accesslevel has been set to ' + level)
return redirect_back('index')
示例2: moderate
# 需要导入模块: from main import PageData [as 别名]
# 或者: from main.PageData import errortext [as 别名]
def moderate():
pd = PageData()
sql = read('imgmods')
result = doquery(sql)
pd.mods = []
pd.tags = Tree('tags')
for mod in result:
try:
imgid = mod[0]
flag = mod[2]
user = mod[3]
if user is None:
user = 'Anonymous'
else:
user = user_by_uid(user)
if mod[1] == 0 or flag == 1:
sql = 'select tag from images where uid = %(uid)s;'
img = doquery(sql, {"uid": imgid})
class Mod:
pass
mod = Mod()
if img:
mod.uid = imgid
mod.tag = img[0][0]
mod.user = user
mod.flag = flag
pd.mods.append(mod)
else:
flash('Error loading data for image ' + str(imgid))
except IndexError as e:
pd.title = "SQL error"
pd.errortext = "SQL error"
return render_template('error.html', pd=pd)
pd.title = "Unmoderated images"
return render_template('moderation.html', pd=pd)
示例3: admin_set_accesslevel
# 需要导入模块: from main import PageData [as 别名]
# 或者: from main.PageData import errortext [as 别名]
def admin_set_accesslevel(user, level):
pd = PageData()
if pd.authuser.accesslevel != 255 and pd.authuser.accesslevel <= int(level):
app.logger.error('Accesslevel change was denied for user: ' + pd.authuser.username)
flash("Access level change denied.")
return redirect_back('index')
try:
moduser = SiteUser.create(user)
if pd.authuser.accesslevel != 255 and moduser.accesslevel >= pd.authuser.accesslevel:
flash("Please contact an admin to modify this user's account.")
return redirect_back('index')
except NoUser:
app.logger.error('Accesslevel change attempted for invalid user by: ' + pd.authuser.username)
pd.title = "User does not exist"
pd.errortext = "The user does not exist"
return render_template('error.html', pd=pd)
moduser.newaccesslevel(level)
flash('User ' + user + '\'s accesslevel has been set to ' + level)
return redirect('/user/' + moduser.username)