def get(self): username = self.request.get("username") ctx = {} if username: # get user from database user = Redditor.get_by_key_name(username) if not user: # create new user from Reddit API data user = Redditor(key_name=username, username=username) data = Redditor.fetch_info(username)["data"] user.joined = datetime.fromtimestamp(data["created"]) user.link_karma = data["link_karma"] user.comment_karma = data["comment_karma"] # calculate shares user.shares = user.calculate_shares() user.put() # update total counters generalcounter.increment("total_shares", user.shares) generalcounter.increment("total_users", 1) ctx['user'] = user ctx['total_shares'] = generalcounter.get_count("total_shares") ctx['total_users'] = generalcounter.get_count("total_users") ctx['share_worth'] = settings.TOTAL_COINS * 1.0 / ctx['total_shares'] ctx['initial_capital'] = ctx['share_worth'] * user.shares ctx['settings'] = settings self.response.out.write(template.render("calc.html", ctx))
def get(self): template_values = { 'simpletotal': simplecounter.get_count(), 'generaltotal': generalcounter.get_count('FOO') } template_file = os.path.join(os.path.dirname(__file__), 'counter.html') self.response.out.write(template.render(template_file, template_values))
def count(cls): return int(generalcounter.get_count('post'))
def _next_segment_name(self): #Returns the name of the next segment in sequence. generalcounter.increment("nextsegment") return str(generalcounter.get_count("nextsegment"))
def get(self): template_values = {"generaltotal": generalcounter.get_count("FOO")} template = jinja_environment.get_template("counter.html") self.response.out.write(template.render(template_values))
def get(self): #if users.is_current_user_admin() or os.environ['SERVER_SOFTWARE'].startswith('Dev'): self.response.out.write('count: ' + str(generalcounter.get_count(PAGE_CREATED_COUNTER)))