Sunday, January 31, 2010

Adding "Remove" function

Not a huge amount of code, but I added an action to delete a run from the tracker.  Basically the run page now has a little trash can next to each run you log.  I found this cool site that has a great page of icons.  I am no design dude, so this was a real life saver.  Selecting the trash can passes the run's BigTable key into the new web action.


class RemoveRunAction(webapp.RequestHandler):
    '''The handler used to remove a Run from the system'''
    def get(self):
        key = self.request.get('key')
        run = Run.get(key)
        run.delete()
        ClearRunCache()
        self.redirect('/')


Like I said, not a lot of code!  Basically get the key from the request, find the run, delete the run, and clear the memcache.  The call I used to clear the cache is memcache.delete which clears the run cache for this one runner only.  It doesn't reset the entire caching system. All the code is updated on github, the links on the left point you to my branch and to the application.  I copy/pasted the code above from github, just noticed it looks a lot better than the copy/paste from eclipse.

No comments:

Post a Comment