Skip to content

Commit

Permalink
updated hello world example with caching
Browse files Browse the repository at this point in the history
  • Loading branch information
Oren Mazor committed Feb 29, 2012
1 parent b7578a9 commit 209b58f
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions widgets/hello_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,24 @@
#
#geckoboard_types is a dictionary of available widget types as defined by geckoboard. see README.

def hello_world(geckoboard_types):
def hello_world(geckoboard_types,cache):

#get the response object to extend
my_widget = geckoboard_types["number_and_secondary_stat"]
my_widget["item"][0]["value"] = 5
my_widget["item"][1]["value"] = 1

#do whatever calculation you need
my_new_value = 5

#update the new value
my_widget["item"][0]["value"] = my_new_value

#get the old one if it exists
if "hello_world_foobar" in cache.keys():
my_widget["item"][1]["value"] = cache["hello_world_foobar"]
else:
my_widget["item"][1]["value"] = 0

#save for next time
cache["hello_world_foobar"] = my_new_value

return my_widget

0 comments on commit 209b58f

Please sign in to comment.