本文整理匯總了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)