def get(self): service = tools.obtain_captcha_service() captcha_random = service.random() captcha_image = service.image() hosted_files = self._count_hosted_files() self.render("uploadform.html", hosted_files=hosted_files, captcha_random=captcha_random, captcha_image=captcha_image)
def _validate_captcha(self): if tools.devel_env(): return True service = tools.obtain_captcha_service() random = self.get_argument("captcha_random", None) password = self.get_argument("captcha_password", None) if random is None or password is None: return False random = tornado.escape.xhtml_escape(random) password = tornado.escape.xhtml_escape(password) logging.debug("Validating captcha (Random: %s, Password: %s)" % (random, password)) return service.validate(random) and service.verify(password)