本文整理匯總了Python中main.PageData.mods方法的典型用法代碼示例。如果您正苦於以下問題:Python PageData.mods方法的具體用法?Python PageData.mods怎麽用?Python PageData.mods使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類main.PageData
的用法示例。
在下文中一共展示了PageData.mods方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: moderate
# 需要導入模塊: from main import PageData [as 別名]
# 或者: from main.PageData import mods [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)