def inject_balance(): user = users.get_current_user() if not user: return dict(balance=0) user_key = ndb.Key('Profile', user.user_id()) profile = user_key.get() return dict(balance=profile.balance)