本文整理汇总了Python中template.Template.update_parameters方法的典型用法代码示例。如果您正苦于以下问题:Python Template.update_parameters方法的具体用法?Python Template.update_parameters怎么用?Python Template.update_parameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类template.Template
的用法示例。
在下文中一共展示了Template.update_parameters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from template import Template [as 别名]
# 或者: from template.Template import update_parameters [as 别名]
def __init__(self, cookie, board=None, dest=None, page=None, perpage=50, **kwargs):
try:
self.user = staff.StaffMember.get_from_cookie(cookie)
except staff.LoginError:
Template.__init__(self, "admin_login_template", login_task=dest)
return
if not dest:
dest = HOME_PANEL
self.admin = cookie
# TODO: Check if mod is banned.
if not page:
if dest in (HOME_PANEL, TRASH_PANEL):
# Adjust for different pagination scheme. (Blame Wakaba.)
page = 0
else:
page = 1
if not str(perpage).isdigit():
perpage = 50
# The page attribute is not always a pure integer (thread pages).
if str(page).isdigit():
page = int(page)
self.page = page
self.perpage = int(perpage)
self.board = local.environ["waka.board"]
if dest not in INTERFACE_MAPPING:
dest = HOME_PANEL
INTERFACE_MAPPING[dest](self, **kwargs)
# Convert user reign list into a list of dictionaries, for
# templating.
reign = []
if self.user.account == staff.MODERATOR:
reign = [{"board_entry": entry} for entry in self.user.reign]
else:
if self.board:
reign = interboard.get_all_boards(check_board_name=self.board.name)
else:
reign = interboard.get_all_boards()
# Set global form variables.
Template.update_parameters(
self,
username=self.user.username,
type=self.user.account,
admin=cookie,
boards_select=reign,
boards=reign,
page=self.page,
perpage=self.perpage,
)