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


Python Event.renderField方法代碼示例

本文整理匯總了Python中wishbone.event.Event.renderField方法的典型用法代碼示例。如果您正苦於以下問題:Python Event.renderField方法的具體用法?Python Event.renderField怎麽用?Python Event.renderField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在wishbone.event.Event的用法示例。


在下文中一共展示了Event.renderField方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: generateEvent

# 需要導入模塊: from wishbone.event import Event [as 別名]
# 或者: from wishbone.event.Event import renderField [as 別名]
    def generateEvent(self, data={}, destination=None):
        '''
        Generates a new event.

        This function can get overridden by
        ``wishbone.module.InputModule._generateNativeEvent``.

        The provided ``data`` will be traversed in search of valid templates
        which then will be rendered.

        Args:
            data (``data``): The payload to add to the event.
            destination (None): The destination key to write the data to

        Returns:
            wishbone.event.Event: An event containing ``data`` as a payload.

        '''
        if destination in [None, "data"]:
            event = Wishbone_Event(data)
            event.renderField(destination, self.env_template)
        else:
            event = Wishbone_Event()
            event.set(data, destination)
            event.renderField(destination, self.env_template)
        return event
開發者ID:smetj,項目名稱:wishbone,代碼行數:28,代碼來源:actor.py

示例2: test_render_field

# 需要導入模塊: from wishbone.event import Event [as 別名]
# 或者: from wishbone.event.Event import renderField [as 別名]
def test_render_field():

    e = Event({"value": "Hello", "template": "{{data.value}} how are you doing?"})
    assert e.get("data.template") == "{{data.value}} how are you doing?"
    e.renderField("data.template")
    assert e.get("data.template") == "Hello how are you doing?"
開發者ID:smetj,項目名稱:wishbone,代碼行數:8,代碼來源:test_event.py


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