本文整理匯總了Python中main.PageData.decode方法的典型用法代碼示例。如果您正苦於以下問題:Python PageData.decode方法的具體用法?Python PageData.decode怎麽用?Python PageData.decode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類main.PageData
的用法示例。
在下文中一共展示了PageData.decode方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: tagreparent
# 需要導入模塊: from main import PageData [as 別名]
# 或者: from main.PageData import decode [as 別名]
def tagreparent():
pd = PageData()
if request.method == 'POST':
if 'username' in session:
userid = pd.authuser.uid
else:
userid = 0
if 'reparent' in request.form:
try:
Tags().reparent(pd.decode(request.form['name']), pd.decode(request.form['reparent']))
except IndexError:
flash('Error reparenting tag!')
return redirect_back('index')
示例2: untag_item
# 需要導入模塊: from main import PageData [as 別名]
# 或者: from main.PageData import decode [as 別名]
def untag_item(item_id, tag_ob):
try:
item = SiteItem.create(item_id)
except NoItem:
return page_not_found()
pd = PageData()
item.remove_tag(pd.decode(tag_ob))
return redirect('/item/' + str(item.uid))
示例3: mod_tag_delete
# 需要導入模塊: from main import PageData [as 別名]
# 或者: from main.PageData import decode [as 別名]
def mod_tag_delete(tag):
pd = PageData()
tree = Tags()
decode_tag = pd.decode(tag)
parent = tree.parent_of(decode_tag)
if tree.delete(decode_tag):
return redirect('/tag/' + pd.encode(parent))
else:
flash('Unable to delete tag: ' + decode_tag)
return redirect_back('/tag/' + tag)
示例4: mod_tag
# 需要導入模塊: from main import PageData [as 別名]
# 或者: from main.PageData import decode [as 別名]
def mod_tag(tag):
pd = PageData()
pd.tree = Tags()
try:
pd.tag = pd.decode(tag)
all_tags = pd.tree.all_children_of(pd.tree.root)
# remove children and ourself from the reparent list
subtract = pd.tree.all_children_of(pd.tag)
subtract.append(pd.tag)
pd.reparent_list = list(set(all_tags) ^ set(subtract))
pd.root_tree = pd.tree.draw_tree(pd.tree.root)
return render_template('tag.html', pd=pd)
except TypeError:
return page_not_found(404)
示例5: newtag
# 需要導入模塊: from main import PageData [as 別名]
# 或者: from main.PageData import decode [as 別名]
def newtag():
pd = PageData()
if request.method == 'POST':
if 'username' in session:
userid = pd.authuser.uid
else:
userid = 0
if 'tag' in request.form:
if request.form['tag'] == '':
return redirect_back('index')
try:
Tags().retrieve(request.form['tag'].strip())
flash('Tag already exists!')
except IndexError:
Tags().insert_children([request.form['tag']], pd.decode(request.form['parent']))
return redirect_back('index')