Skip to content

Commit

Permalink
deal with the incorrent id & version 5.
Browse files Browse the repository at this point in the history
  • Loading branch information
ydoovv committed Dec 5, 2010
1 parent c23158f commit 7fa33b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app.yaml
@@ -1,5 +1,5 @@
application: digest-favs
version: 4
version: 5
runtime: python
api_version: 1

Expand Down
9 changes: 8 additions & 1 deletion main.py
Expand Up @@ -4,6 +4,7 @@

import os
import re
import logging

from google.appengine.ext import db
from google.appengine.ext import webapp
Expand Down Expand Up @@ -39,7 +40,13 @@ def get(self):
proxy = 'http://ydoovv.appspot.com/' # a twitter api proxy, or handle yourself
url = '%s/favorites/%s.json?page=%s' % (proxy, id_, page)
res = urlfetch.fetch(url)
favs = json.loads(res.content)
if res.content[0] not in ('[', '{'):
logging.error('BAD_FETCH: %s' % url)
template_values["flashes"] = 'Bad request!'
self.render(template_values)
return
else:
favs = json.loads(res.content)
if isinstance(favs, dict): # {"request": "oooo", "error": "xxxx"}
template_values["flashes"] = favs["error"]
self.render(template_values)
Expand Down

0 comments on commit 7fa33b6

Please sign in to comment.