本文整理汇总了Python中models.event.Event.payload方法的典型用法代码示例。如果您正苦于以下问题:Python Event.payload方法的具体用法?Python Event.payload怎么用?Python Event.payload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.event.Event
的用法示例。
在下文中一共展示了Event.payload方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: push_event
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import payload [as 别名]
def push_event(cls,
endpoint,
payload=None,
method='POST',
headers=None,
priority=0,
group_id=None):
"""
Will push an event to the event queue.
endpoint: URL to call while executing the event
payload: Dictionary of GET params or body JSON
method: GET|POST
headers: Headers while executing the request
priority: Will be used to block events while lower priorities
events have failed. An event will only execute
if it' the next top priority on that group
group_id: Grouping of events, if None, an event will have it's
own unique group
"""
if not payload:
payload = {}
if not group_id:
group_id = guid()
event = Event()
event.created = datetime.datetime.now()
event.headers = json.dumps(headers) or ''
event.method = method
event.payload = json.dumps(payload)
event.endpoint = endpoint
event.status = EventStatus.CREATED
event.priority = priority
event.group_id = group_id
event.put()
q = taskqueue.Queue(QUEUE_NAME)
q.add([taskqueue.Task(
name=cls._get_cutie_task_name(event.unique_id),
payload=event.unique_id,
method='PULL'
)])