Пример #1
0
 def _api_display_list_(self, list_to_display):
     """ Displays list with the given id in JSON format """
     self.response.headers['Content-Type'] = 'application/json'
     items = list_to_display.get_items()
     if len(items) > 0:
         list_to_display.items = to_JSON(items)
     response = json.dumps(list_to_display.to_dict())
     self.response.out.write(response)
Пример #2
0
 def build_data():
     """ Build the data for searching if it's not in memcache """
     #all_products = Product.all().fetch(1500)
     all_products = db.Query(Product, projection=['name']).fetch(15000)
     ret = defaultdict(list)
     logging.info('Product count: ' + str(len(ret)))
     for product in all_products:
         for word in product.name.lower().split(' '):
             term = ''
             for char in word:
                 term = term + char
                 ret[term].append({'id': product.key().id_or_name(), 'name': product.name})
     for key, value in ret.iteritems():
         helper = SearchHelper(key_name=key)
         helper.items = to_JSON(value)
         helper.put()
     return ret
Пример #3
0
 def _api_list_lists_(self, all_lists):
     """ Lists all shopping lists as JSON """
     self.response.headers['Content-Type'] = 'application/json'
     response_json = to_JSON(all_lists)
     self.response.out.write(response_json)