def authorize(referrer): if not users.get_current_user(): return login(referrer) else: cache_key='{0}/authorizations'.format(request.referrer) auth=cache.get(cache_key) email=db.Email(users.get_current_user().email()) if auth is None: auth=Authorization.get_by_key_name(request.referrer) if auth is not None: cache.set(cache_key, auth) try: a=auth.approved.index(email) except ValueError: a=-1 if a <> -1: return logout(referrer) else: try: p=auth.pending.index(email) except ValueError: p=-1 if p <> -1: return pending_logout(referrer) else: try: r=auth.rejected.index(email) except ValueError: r=-1 if r <> -1: return rejected_logout(referrer) return authorize_logout(referrer)
def fishing(): swarm=[] updates={} for fish in fishes(): swarm.append({'name':fish['name'], 'price':fish['price'], 'image':fish['image'], 'date':fish['date']}) for fish in swarm: cache_key = fish['name'] try: v=updates[cache_key] except KeyError: v = cache.get(cache_key) if v is None: q=Quotes.gql("WHERE fish = :1", cache_key) v=q.get() if v is None: v=Quotes(fish=fish['name'], prices={}, image=re.sub(r'..(.*)',r'http://www.tcfishery.com\1',fish['image'])) v.prices[fish['date']]=fish['price'] updates[cache_key]=v for v in updates.values(): v.put() cache.set(v.fish, v)