本文整理匯總了Python中askbot.models.Post.add_to_class方法的典型用法代碼示例。如果您正苦於以下問題:Python Post.add_to_class方法的具體用法?Python Post.add_to_class怎麽用?Python Post.add_to_class使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類askbot.models.Post
的用法示例。
在下文中一共展示了Post.add_to_class方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _askbot_ext_action
# 需要導入模塊: from askbot.models import Post [as 別名]
# 或者: from askbot.models.Post import add_to_class [as 別名]
returns None anf an AttributeError has to be catched
(the method will then return False)
"""
rv = False
# Use parent.is_question is OK because we are sure that parent is not None
# (parent would be None if self.is_question())
if self.is_comment() and self.parent.is_question():
rv = True
return rv
@property
def _askbot_ext_action(self):
"""Encapsulation of action reference"""
return self.thread.action
Post.add_to_class('ext_noattr', PostExtension())
#--------------------------------------------------------------------------------
#TODO: place can be blank/null at creation time?
#TODO TOTHINK User.add_to_class("place", models.CharField(max_length=512))
#--------------------------------------------------------------------------------
class VoteExtension(AskbotModelExtender):
@property
def _askbot_ext_action(self):
"""Encapsulation of action reference"""
return self.voted_post.action
示例2: _askbot_ext_action
# 需要導入模塊: from askbot.models import Post [as 別名]
# 或者: from askbot.models.Post import add_to_class [as 別名]
returns None anf an AttributeError has to be catched
(the method will then return False)
"""
rv = False
# Use parent.is_question is OK because we are sure that parent is not None
# (parent would be None if self.is_question())
if self.is_comment() and self.parent.is_question():
rv = True
return rv
@property
def _askbot_ext_action(self):
"""Encapsulation of action reference"""
return self.thread.action
Post.add_to_class('ext_noattr', PostExtension())
Post.add_to_class('title', models.CharField(default='',max_length=256)
)
#--------------------------------------------------------------------------------
#TODO: place can be blank/null at creation time?
#TODO TOTHINK User.add_to_class("place", models.CharField(max_length=512))
#--------------------------------------------------------------------------------
class VoteExtension(AskbotModelExtender):
@property
def _askbot_ext_action(self):