def get(self, week, session_id): client_id = self.request.get('client_id') if client_id: query = SyncSession.query( SyncSession.client == ndb.Key(urlsafe=client_id), SyncSession.status == True ) sessions = query.fetch(FETCH_LIMIT) self.resp = [] if sessions: self.resp = self.json_list(sessions) else: week = int(week) session = SyncSession.query(SyncSession.key == self.current_key, SyncSession.week == week).get() self.resp = {} if session: self.resp = session.to_json() self.format_resp()