Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 访问Requesthandler外部的变量_Html_Css_Tornado - Fatal编程技术网

Html 访问Requesthandler外部的变量

Html 访问Requesthandler外部的变量,html,css,tornado,Html,Css,Tornado,我正在使用CSS3手风琴效果,我想检测黑客是否会 制作脚本以进行并行请求;即: 我在同一页上有一个登录表单和一个注册表单,但只有一个 一个是可见的,因为有一个CSS3:要访问页面,用户 代理必须与HTML5兼容。 我使用的技巧是: class Register(tornado.web.RequestHandler): def post(self): tt = self.get_argument("_xsrf") + str(time.time())

我正在使用CSS3手风琴效果,我想检测黑客是否会 制作脚本以进行并行请求;即: 我在同一页上有一个登录表单和一个注册表单,但只有一个 一个是可见的,因为有一个CSS3:要访问页面,用户 代理必须与HTML5兼容。 我使用的技巧是:

class Register(tornado.web.RequestHandler): 
    def post(self): 
        tt = self.get_argument("_xsrf") + str(time.time()) 
        rtime = float(tt.replace(self.get_argument("_xsrf"), "")) 
        print rtime 
class LoginHandler(BaseHandler): 
    def post(self): 
        tt = self.get_argument("_xsrf") + str(time.time()) 
        ltime = float(tt.replace(self.get_argument("_xsrf"), "")) 
        print ltime 
我使用了
xsrf
变量,因为它对于每个用户都是唯一的,可以 避免让服务器认为请求来自同一服务器 机器。 现在我想要的是:如何区分时间值:
abs(ltime-rtime)
;我的意思是,我如何在课外访问rtime, 我只知道如何访问方法之外的值,我想 此操作检测值是否小,则用户正在使用 一个脚本,用于发出并行请求以终止服务器! 换句话说(对于一般python用户) 如果我有:

class Product: 
   def info(self): 
       self.price = 1000 
   def show(self): 
       print self.price 
>>> car = Product() 
>>> car.info() 
>>> car.show() 

1000 
但是如果我有另一个呢

class User: 
    pass 
那么,如何制作一个方法来打印我自己的价格,我已经尝试过了 继承,但出现错误:AttributeError:用户实例没有
属性“
price
”,因此只传递方法,而不传递属性

听起来您需要了解使用持久存储数据的模型对象和模式
tornado.web.RequestHandler
和从中生成子类的任何对象仅在请求期间存在。从服务器上接收URL到通过
self.write()
self.finish()
将数据发送回浏览器


我建议您阅读一些Django或了解一些关于如何用Python构建MVC应用程序的基本想法(据我所知,没有Tornado教程介绍这方面的内容)

谢谢:D所以,据我所知,没有办法避免两个处理程序的并行执行?在tornado中,执行是串行的,除非通过get()/post()/request处理程序方法上的@asynchronous decorator生成它。因为它不是多线程的,所以即使经过修饰,你仍然只有一个执行路径。但是如果我使用获取时间的技术,如果它没有执行,那么它是零,否则,它将是一个值,如果它是一个值,这个值不能太小,这是我的想法,如果您正在重载xsrf进行会话管理,那么您应该考虑使用
self.set_secure_cookie(…)
来管理会话状态。xsrf只是一个黑客,目的是获取一个唯一的id,以避免在用户可以同时调用的相同请求处理程序之间混合。