Exemple #1
0
          taskqueue.add(url='/fetch_foursquare_data/all_for_user/%s' % userinfo.key())
        except foursquare.FoursquareRemoteException, err:
          if str(err).find('403 Forbidden') >= 0:
            pass # if a user tries to sign up while my app is blocked, then it currently just redirects to the signup page
                 #TODO find a better way to handle this case, but it's not clear there is a simple way to do it without messing up a bunch of code
          else:
            raise err
        except DownloadError:
          pass #TODO make this better, but I'd rather throw the user back to the main page to try again than show the user an error.
        self.redirect("/")
      else:
        fs, credentials = get_new_fs_and_credentials()
        app_token = fs.request_token()
        auth_url = fs.authorize(app_token)
        new_apptoken = AppToken(token = app_token.key, secret = app_token.secret)
        new_apptoken.put()
        self.redirect(auth_url)
    else:
      self.redirect(users.create_login_url(self.request.uri))

class StaticMapHandler(webapp.RequestHandler):
  def get(self):
    path = environ['PATH_INFO']
    if path.endswith('.png'):
      raw = path[:-4] # strip extension
      try:
        assert raw.count('/') == 2, "%d /'s" % raw.count('/')
        foo, bar, map_key = raw.split('/')
      except AssertionError, err:
        logging.error(err.args[0])
        return