def _cache_next(self): now = datetime.now() key = self._next_key_gen() val = self.get_argument("next", "/") c = Cache() c.key = key c.value = val c.expire = now + timedelta(seconds=600) value = c.findby_key(key) if value: c.save(value["_id"]) else: c.insert()
def _login_redirect(self, status_): key = self._next_key_gen() c = Cache() value = c.findby_key(key) if value: next = escape.utf8(value["value"]) c.remove(value["_id"]) else: next = "/" #next = self.get_argument("next", "/") if status_ == const.Status.INIT: self.redirect("/user/profile?next=%s" % next) else: self.redirect(next)
def remove(key): """Remove a cache's value.""" c = Cache() v = c.findby_key(key) if v: c.remove(v["_id"])