def post(self): gcm = cgi.escape(self.request.get('gcm_handle')) lines = self.parse_lines() try: registration = PushNotificationRegistration(gcm_handle=gcm, lines_interested=lines) registration.put() except Exception as e: logging.warning( 'Failed to create PushNotificationRegistration: %s', e) self.response.set_status(400)
def post(self): gcm = cgi.escape(self.request.get('gcm_handle')) lines = self.parse_lines() try: registration = PushNotificationRegistration( gcm_handle = gcm, lines_interested = lines) registration.put() except Exception as e: logging.warning('Failed to create PushNotificationRegistration: %s', e) self.response.set_status(400)
def inject_many_users(size=1000, batch_size=1000): odds = { 1: 0.26, 2: 0.46, 3: 0.15, 4: 0.05, 5: 0.01, 6: 0.01, 7: 0.01, 8: 0.01, 9: 0.01, 10: 0.01, 11: 0.01, 12: 0.01 } batch = [] for _ in xrange(size): n = pick_n_lines(odds) r = str(random.random()) lines = random.sample(LINES, n) registration = PushNotificationRegistration(gcm_handle=r, lines_interested=lines) batch.append(registration) if len(batch) == batch_size: db.put(batch) batch = [] if batch: db.put(batch) batch = []
def get(self): PushNotificationRegistration.delete_outdated_registrations()
def get(self): self.response.headers['Content-Type'] = 'text/plain' c = PushNotificationRegistration.all(keys_only=True).count(1000 * 1000) self.response.write('Yo world - %d rows' % c)
def get(self): self.response.headers['Content-Type'] = 'text/plain' c = PushNotificationRegistration.all(keys_only=True).count(1000*1000) self.response.write('Yo world - %d rows'%c)