本文整理匯總了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)