本文整理匯總了Python中main.PageData.title方法的典型用法代碼示例。如果您正苦於以下問題:Python PageData.title方法的具體用法?Python PageData.title怎麽用?Python PageData.title使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類main.PageData
的用法示例。
在下文中一共展示了PageData.title方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: edititem
# 需要導入模塊: from main import PageData [as 別名]
# 或者: from main.PageData import title [as 別名]
def edititem(item_id=None):
pd = PageData()
if request.method == 'POST':
if 'username' in session:
userid = pd.authuser.uid
else:
userid = 0
if 'desc' in request.form:
if request.form['name'] == '':
flash('No name for this item?')
return redirect_back("/item/new")
try:
item = SiteItem.create(request.form['uid'])
item_id = uid_by_item(request.form['name'])
if not item_id or item_id == int(request.form['uid']):
uid = request.form['uid']
ip = request.remote_addr
if item.name != request.form['name']:
item.name = request.form['name']
item.update()
old = core.digest(item.body())
new = core.digest(request.form['desc'])
# silently discard null edits
if old != new:
new_edit(uid, request.form['desc'], userid, ip)
logger.info('item {} edited by user {} ({})'.format(uid, userid, ip))
else:
logger.info('null edit discarded for item {} by user {} ({})'.format(uid, userid, ip))
return redirect('/item/' + str(uid))
else:
flash(item.name + " already exists!")
item_id = request.form['uid']
except NoItem:
if uid_by_item(request.form['name']):
flash(request.form['name'] + " already exists!")
return redirect_back("/item/new")
uid = new_item(request.form['name'], request.form['desc'], userid, request.remote_addr)
return redirect('/item/' + str(uid))
if item_id:
try:
pd.item = SiteItem.create(item_id)
except NoItem:
return page_not_found()
pd.title="Editing: %s" % pd.item.name
else:
pd.title="Editing: New Item"
return render_template('edititem.html', pd=pd)
示例2: newuser
# 需要導入模塊: from main import PageData [as 別名]
# 或者: from main.PageData import title [as 別名]
def newuser():
pd = PageData();
pd.title = "New User"
if 'username' in session:
flash('You are already logged in.')
return redirect(url_for('index'))
else:
if request.method == 'POST':
if not check_new_user(request):
pd.username = request.form['username']
pd.email = request.form['email']
return render_template('new_user.html', pd=pd)
if not new_user(request.form['username'], request.form['password'], request.form['email'], request.remote_addr):
return render_template('error.html', pd=pd)
try:
user = SiteUser.create(request.form['username'])
user.authenticate(request.form['password'])
session['username'] = user.username
except (NoUser, AuthFail):
return render_template('error.html', pd=pd)
flash('Welcome ' + request.form['username'])
return redirect(url_for('index'))
return render_template('new_user.html', pd=pd)
示例3: admin_set_accesslevel
# 需要導入模塊: from main import PageData [as 別名]
# 或者: from main.PageData import title [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')
示例4: moderate
# 需要導入模塊: from main import PageData [as 別名]
# 或者: from main.PageData import title [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)
示例5: show_image
# 需要導入模塊: from main import PageData [as 別名]
# 或者: from main.PageData import title [as 別名]
def show_image(img_id):
pd = PageData()
try:
pd.img = SiteImage.create(img_id)
pd.title=pd.img.tag
except NoImage:
return page_not_found(404)
return render_template('image.html', pd=pd)
示例6: show_user_profile
# 需要導入模塊: from main import PageData [as 別名]
# 或者: from main.PageData import title [as 別名]
def show_user_profile(username):
pd = PageData()
pd.title = "Profile for " + username
try:
pd.profileuser = SiteUser.create(username)
except NoUser:
return page_not_found()
return render_template('profile/main.html', pd=pd)
示例7: stats
# 需要導入模塊: from main import PageData [as 別名]
# 或者: from main.PageData import title [as 別名]
def stats():
pd = PageData()
pd.title = "Scarf Stats"
pd.topcollectors = get_whores_table()
pd.topcontributors = get_contribs_table()
pd.topneedy = get_needy_table()
pd.topwilltrade = get_willtrade_table()
return render_template('stats.html', pd=pd)
示例8: show_user_profile_collections
# 需要導入模塊: from main import PageData [as 別名]
# 或者: from main.PageData import title [as 別名]
def show_user_profile_collections(username):
pd = PageData()
pd.title = "Collections for " + username
pd.timezones = get_timezones()
try:
pd.profileuser = SiteUser.create(username)
except NoUser:
return page_not_found()
return render_template('profile/collections.html', pd=pd)
示例9: show_user_profile
# 需要導入模塊: from main import PageData [as 別名]
# 或者: from main.PageData import title [as 別名]
def show_user_profile(username):
pd = PageData()
pd.title = "Profile for " + username
pd.timezones = get_timezones()
try:
pd.profileuser = SiteUser.create(username)
except NoUser:
return page_not_found(404)
return render_template('profile.html', pd=pd)
示例10: show_item_history
# 需要導入模塊: from main import PageData [as 別名]
# 或者: from main.PageData import title [as 別名]
def show_item_history(item_id):
pd = PageData()
try:
showitem = SiteItem.create(item_id)
except NoItem:
return redirect("/item/" + item_id + "/edit")
pd.title = showitem.name
pd.item = showitem
return render_template('itemhistory.html', pd=pd)
示例11: show_user_profile_prefs
# 需要導入模塊: from main import PageData [as 別名]
# 或者: from main.PageData import title [as 別名]
def show_user_profile_prefs(username):
pd = PageData()
pd.title = "Preferences for " + username
pd.timezones = get_timezones()
if not hasattr(pd, 'authuser') or pd.authuser.username != username:
return page_not_found()
try:
pd.profileuser = SiteUser.create(username)
except NoUser:
return page_not_found()
return render_template('profile/preferences.html', pd=pd)
示例12: reallydelete_image
# 需要導入模塊: from main import PageData [as 別名]
# 或者: from main.PageData import title [as 別名]
def reallydelete_image(img_id):
pd = PageData()
try:
delimg = SiteImage.create(img_id)
delimg.delete()
except NoImage:
return page_not_found(404)
pd.title = delimg.tag + " has been deleted"
pd.accessreq = 10
pd.conftext = delimg.tag + " has been deleted. I hope you meant to do that."
pd.conftarget = ""
pd.conflinktext = ""
return render_template('confirm.html', pd=pd)
示例13: revert_item_edit
# 需要導入模塊: from main import PageData [as 別名]
# 或者: from main.PageData import title [as 別名]
def revert_item_edit(item_id, edit):
pd = PageData()
try:
item = SiteItem.create(item_id)
item.old = True
item.edit = edit
except NoItem:
return page_not_found()
pd.title="Reverting: " + item.name
pd.item_name = item.name
pd.item = item
return render_template('edititem.html', pd=pd)
示例14: delete_item
# 需要導入模塊: from main import PageData [as 別名]
# 或者: from main.PageData import title [as 別名]
def delete_item(item_id):
try:
delitem = SiteItem.create(item_id)
except NoItem:
return page_not_found()
pd = PageData()
pd.title=delitem.name
pd.accessreq = 255
pd.conftext = "Items may take some time to disappear from the indexes."
pd.conftarget = "/item/" + str(delitem.uid) + "/reallydelete"
pd.conflinktext = "I want to delete '{}' and accept the consequences of this action.".format(delitem.name)
return render_template('confirm.html', pd=pd)
示例15: show_image
# 需要導入模塊: from main import PageData [as 別名]
# 或者: from main.PageData import title [as 別名]
def show_image(img_id):
"""
:URL: /image/<img_id>
Render a template for viewing an image.
"""
pd = PageData()
try:
pd.img = SiteImage.create(img_id)
pd.title=pd.img.tag
except NoImage:
return page_not_found()
return render_template('image.html', pd=pd)