2020-06-09 05:15:43 +00:00
|
|
|
"""
|
|
|
|
Demonstrates the behavior of the callback field.
|
|
|
|
"""
|
|
|
|
# Standard library imports
|
2020-06-09 05:38:33 +00:00
|
|
|
from datetime import datetime
|
2020-06-09 05:15:43 +00:00
|
|
|
import random
|
|
|
|
|
|
|
|
def fetch_new(state):
|
|
|
|
itemid = '{:x}'.format(random.getrandbits(16 * 4))
|
|
|
|
item = {
|
|
|
|
'source': "callbackdemo",
|
|
|
|
'id': itemid,
|
|
|
|
'title': f"Callback demo",
|
|
|
|
'body': 'No callbacks',
|
|
|
|
'callback': { 'id': itemid }
|
|
|
|
}
|
|
|
|
return [item]
|
|
|
|
|
|
|
|
def callback(state, item):
|
2020-06-09 05:38:33 +00:00
|
|
|
item['body'] = f"Last callback at {datetime.now()}"
|