def get(self):
    self.sess = sessions.Session()
    if not self.sess.has_key("model_test"):
        self.sess["model_test"] = SessionTestModel(testval="test")
        self.sess["model_test"].put()
        # give the datastore time to submit the commit
        time.sleep(1)
    self.cookie_sess = sessions.Session(writer="cookie")
    if self.request.get('deleteSession') == "true":
        self.sess.delete()
        print "Location: /session\n\n"
    elif self.request.get('setflash') == "true":
        self.sess['flash'] = 'You set a flash message! <a href="/session">Refresh this page</a> and this message is gone!'
        print "Location: /session\n\n"
    elif self.request.get('setTestKey') == "true":
        self.sess['DeletableKey'] = 'delete me'
        print "Location: /session\n\n"
    elif self.request.get('clearTestKey') == "true":
        self.sess.delete_item('DeletableKey')
        print "Location: /session\n\n"
    else:
        keyname = 'testKey'
        self.sess[keyname] = "test"
        self.sess[keyname + '2'] = "test2"
        self.sess[3] = "test3"
        self.cookie_sess['cookie_test'] = "testing cookie values"
        self.sess[u"unicode_key"] = u"unicode_value"

        if not 'viewCount' in self.sess:
            self.sess['viewCount'] = 1
        else:
            self.sess['viewCount'] = int(self.sess['viewCount']) + 1
        self.sess["model_test"].testval = unicode(self.sess['viewCount'])
        testkey = self.sess["model_test"].put()
        session_length = len(self.sess)
        self.memcacheStats = memcache.get_stats()
        template_values = {
            'sess': self.sess,
            'sess_str': str(self.sess),
            'cookie_sess': self.cookie_sess,
            'session_length': session_length,
            'memcacheStats': self.memcacheStats,
            'model_test': self.sess["model_test"].testval,
            'testkey': testkey,
        }
        path = os.path.join(os.path.dirname(__file__), 'templates/session-new.html')
        self.response.out.write(template.render(path, template_values))
dataset/ETHPy150Open joerussbowman/gaeutilities/main.py/SessionPage.get/original