當前位置: 首頁>>代碼示例>>Python>>正文


Python Post.add_to_class方法代碼示例

本文整理匯總了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
開發者ID:matteo88,項目名稱:open-action,代碼行數:32,代碼來源:models.py

示例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):
開發者ID:in6kPythonDev,項目名稱:open-action,代碼行數:33,代碼來源:models.py


注:本文中的askbot.models.Post.add_to_class方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。