示例#1
0
文件: main.py 项目: cmds4410/WBOR
 def get(self):
     self.response.headers["Content-Type"] = "text/json"
     album_key = self.request.get("album_key")
     songlist_html = memcache.get("songlist_html_" + album_key)
     if songlist_html:
         self.response.out.write(
             json.dumps({
                 'songListHtml': songlist_html,
                 'generated': 'memcache',
             }))
         return
     album = cache.getAlbum(album_key)
     self.response.headers["Content-Type"] = "text/json"
     if not album:
         self.response.out.write(
             json.dumps({
                 'err':
                 "An error occurred and the specified album could not be found.  Please try again."
             }))
         return
     songlist_html = template.render(getPath("ajax_songlist.html"), {
         'songList': [cache.getSong(k) for k in album.songList],
     })
     memcache.set("songlist_html_" + album_key, songlist_html)
     self.response.out.write(
         json.dumps({
             'songListHtml':
             template.render(getPath("ajax_songlist.html"), {
                 'songList': [cache.getSong(k) for k in album.songList],
             }),
             'generated':
             'generated',
         }))
示例#2
0
文件: main.py 项目: cmds4410/WBOR
 def get(self):
     self.response.headers["Content-Type"] = "text/json"
     album_key = self.request.get("album_key")
     songlist_html = memcache.get("songlist_html_" + album_key)
     if songlist_html:
         self.response.out.write(json.dumps({"songListHtml": songlist_html, "generated": "memcache"}))
         return
     album = cache.getAlbum(album_key)
     self.response.headers["Content-Type"] = "text/json"
     if not album:
         self.response.out.write(
             json.dumps({"err": "An error occurred and the specified album could not be found.  Please try again."})
         )
         return
     songlist_html = template.render(
         getPath("ajax_songlist.html"), {"songList": [cache.getSong(k) for k in album.songList]}
     )
     memcache.set("songlist_html_" + album_key, songlist_html)
     self.response.out.write(
         json.dumps(
             {
                 "songListHtml": template.render(
                     getPath("ajax_songlist.html"), {"songList": [cache.getSong(k) for k in album.songList]}
                 ),
                 "generated": "generated",
             }
         )
     )
示例#3
0
文件: api.py 项目: hchapman/WBOR
 def get(self, key):
   album = cache.getAlbum(key)
   logging.debug(album.to_json())
   if album is not None:
     self.json_respond(album.to_json())
示例#4
0
 def get(self, key):
     album = cache.getAlbum(key)
     logging.info(album.to_json())
     if album is not None:
         self.json_respond(album.to_json())