def post(self): eid = self.request.get('id', default_value='') self.response.write('<h1>'+eid+'</h1>') key = self.request.get('key', default_value='') if eid is not None and eid != '': msg = Message.get_by_id(int(eid)) elif key is not None and key != '': msg = ndb.Key(urlsafe=key).get() else: self.err('Neither id or key is passed!\n') return if msg is None: self.err('Loading message failed!\n') return # Send to phone notification! usr = User() usr.hash = msg.recipient usr = usr.loadme() if usr is None: self.err('User-Recipient not found!'); return data = {'type': 'message', 'sender': msg.sender} notfication = GCM('AIzaSyD-z2JuoBkD51RyRHG6ULoWX2gE84apP7M') response = notfication.json_request(registration_ids=usr.registration_ids, data=data, collapse_key=None, delay_while_idle=False, time_to_live=None, retries=5) self.response.headers['Content-Type'] = 'application/json; charset=utf-8' self.debug(response) # Mark message as pushed. msg.pushed = datetime.now() msg.put()