本文整理汇总了Python中forms.TopicForm.init方法的典型用法代码示例。如果您正苦于以下问题:Python TopicForm.init方法的具体用法?Python TopicForm.init怎么用?Python TopicForm.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.TopicForm
的用法示例。
在下文中一共展示了TopicForm.init方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from forms import TopicForm [as 别名]
# 或者: from forms.TopicForm import init [as 别名]
def get(self):
node_id = force_int(self.get_argument('node_id', 0), 0)
node = Node.get(id=node_id)
if node:
selected = node.name
else:
selected = None
choices = Node.get_node_choices()
form = TopicForm.init(choices=choices, selected=selected)
return self.render("topic/create.html", form=form, node=node)
示例2: get
# 需要导入模块: from forms import TopicForm [as 别名]
# 或者: from forms.TopicForm import init [as 别名]
def get(self, topic_id):
topic = Topic.get(id=topic_id)
if topic and (topic.author == self.current_user or self.current_user.is_admin):
selected = topic.node.name
else:
return self.redirect_next_url()
choices = Node.get_node_choices()
args = {'node_name': [selected], 'title': [topic.title], 'content':
[topic.content]}
form = TopicForm.init(choices=choices, selected=selected, args=args)
return self.render("topic/create.html", form=form, node=topic.node)
示例3: get
# 需要导入模块: from forms import TopicForm [as 别名]
# 或者: from forms.TopicForm import init [as 别名]
def get(self, topic_id):
if not self.has_permission:
return
topic = Topic.get(id=topic_id)
if topic:
selected = topic.node.name
else:
return self.redirect_next_url()
choices = Node.get_node_choices()
args = {'node_name': [selected], 'title': [topic.title], 'content':
[topic.content]}
form = TopicForm.init(choices=choices, selected=selected, args=args)
return self.render("topic/create.html", form=form, node=topic.node)