#NEWLINE# @ classmethod #NEWLINE# def _HandleBadPushToken( cls , client , push_token , timestamp = None , callback = None ) : #NEWLINE# #INDENT# "Callback in the event of failed delivery of push notification.\n    'push_token' is queried via the secondary index on Device. Timestamp\n    is the time at which the delivery failed. If the device attached to\n    the failed push_token has 'last_access' > timestamp, ignore failure;\n    otherwise, clear the push token and update.\n    " #NEWLINE# def _OnQueryByPushToken( devices ) : #NEWLINE# #INDENT# if ( not devices ) : #NEWLINE# #INDENT# logging . warning ( ( 'unable to locate device for push token: %s' % push_token ) ) #NEWLINE# return #NEWLINE# #UNINDENT# for device in devices : #NEWLINE# #INDENT# if ( ( device . last_access is None ) or ( device . last_access < timestamp ) ) : #NEWLINE# #INDENT# logging . info ( ( 'unsetting push_token for device %s' % device ) ) #NEWLINE# device . push_token = None #NEWLINE# device . Update ( client , ( callback if callback else util . NoCallback ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# query_expr = ( 'device.push_token={t}' , { #NEWLINE# #INDENT# 't' : query_expr , #NEWLINE# #UNINDENT# } ) #NEWLINE# Device . IndexQuery ( client , query_expr , None , _OnQueryByPushToken )