def post(self): submitted_quote = self.request.get(self.http_post_quote_key) quote_submitter = self.request.get(self.http_post_user_key) success = False if len(submitted_quote) <= self.max_quote_size and len(submitted_quote) >= self.min_quote_size: success = True tlq_util.put_in_quote_set(tlq_util.form_quote(submitted_quote, quote_submitter)) tlq_util.write_out_json(self.response, success)
def get(self): if self.request.get(self.http_post_user_key) != "": tlq_util.write_out_json( self.response, [ quote.to_dict() for quote in tlq_util.fetch_quotes_for_user_uuid(self.request.get(self.http_post_user_key)) ], ) elif self.request.get(self.http_get_clear_user_quotes_key) != "": tlq_util.clear_user_quotes_in_datastore(self.request.get(self.http_get_clear_user_quotes_key)) else: current_quote = tlq_util.get_random_quote(self.request.get(self.http_get_last_quote_uuid_key)) if current_quote is None: current_quote = tlq_util.form_quote(self.default_return_quote) tlq_util.write_out_json(self.response, current_quote)