本文整理汇总了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')