属性访问拦截器 

class Itcast(object):
def __init__(self,subject1):
self.subject1 = subject1
self.subject2 = "go"
#属性访问拦截器,打log
def __getattribute__(self, item):
print("---1>%s" %item)
if item == "subject1":
print("log subject1")
return 'redirect python'
else:
temp = object.__getattribute__(self,item)
print("---2>%s"%str(temp))
return temp
def show(self):
print("this is Itcast") s = Itcast("python")
print("--------1--------")
print(s.subject1)
print("--------2--------")
print(s.subject2)
print("--------3--------")
s.show()
print("--------4--------")

  输出

--------1--------
---1>subject1
log subject1
redirect python
--------2--------
---1>subject2
---2>go
go
--------3--------
---1>show
---2><bound method Itcast.show of <__main__.Itcast object at 0x000001F47161A860>>
this is Itcast
--------4--------

  

getattribute的更多相关文章

  1. request中getParameter和getAttribute的区别

    整理一下getParameter和getAttribute的区别和各自的使用范围. (1)HttpServletRequest类有setAttribute()方法,而没有setParameter()方 ...

  2. getAttribute、setAttribute、removeAttribute

    1.函数语法 elementNode.attributes:属性返回包含被选节点属性的 NamedNodeMap. elementNode.getAttribute(name):方法通过名称获取属性的 ...

  3. request:getParameter getAttribute

    转载自:http://www.cnblogs.com/shaohz2014/p/3804656.html 在浏览器地址输入,表示传入一个参数test,值为123 http://localhost:88 ...

  4. sizzle分析记录:getAttribute和getAttributeNode

    部分IE游览器下无法通过getAttribute取值? <form name="aaron"> <input type="text" name ...

  5. request属性 request.getAttribute()

    一.request.getParameter() 和request.getAttribute() 区别 (1)request.getParameter()取得是通过容器的实现来取得通过类似post,g ...

  6. request getParameter getAttribute

    在浏览器地址输入,表示传入一个参数test,值为123 http://localhost:8888/Test/index.jsp?test=123 在index.jsp中尝试使用EL表达式取出,代码如 ...

  7. setAttribute,,,getAttribute,,,,

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  8. JQuery 1.8.3对IE9兼容问题getAttribute

    jQuery1.8.3在IE9下attr报错问题 jQuery1.8.3在IE9中attr方法保存. 解决方案如下: r = e.getAttribute(n); 修改为: r = e.getAttr ...

  9. getattribute()与getparameter()的区别

    1.它们取到的值不同.getAttribute取到的是对象(object),而getParameter取到的是String. 2.数据传递路劲不同.request.getParameter方法传递的数 ...

  10. 【JSP手记】--jsp里面session.getAttribute("×××")在java中的表示

    JSP里面的    <%=session.getAttribute("×××")%> 与java等价于         request.getSession().get ...

随机推荐

  1. SAP发布REST/HTTP接口

    1.SE24新建类:ZCL_REST_QUERY 激活,然后添加interface:IF_HTTP_EXTENSION并激活. 2.实现IF_HTTP_EXTENSION~HANDLE_REQUEST ...

  2. python -- 约束、异常处理、MD5

    1.类的约束       1.写一个父类,父类中的某个方法要抛出一个异常 NotImplementedError class Base: # 对子类进行了约束,必须重写该方法 def login(se ...

  3. linux如何让一个程序崩溃后自动重启

    思路:  写一个脚本 监控程序的运行状态  没有运行启动运行 已运行不做操作. 如果在控制台启动脚本 注意必须  nohup sh xxx.sh & while true do ps -ef ...

  4. xftp免费版使用

    转自https://www.jb51.net/softs/621774.html

  5. learning makefile = and :=

  6. Linux目录结构 重要目录结构详细

    1.1 /etc/hosts ip地址与主机名(域名)的对应关系  解析主机名  ping www.baidu.com 解析成10.0.0.200 1.产品测试 2  用主机名互相访问 1.2 /et ...

  7. spring+springMvc+struts的SSH框架整合

    1.建立一个web项目 2.导入SSH框架所需jar包 3.配置web.xml文件 <?xml version="1.0" encoding="UTF-8" ...

  8. RN环境的搭建

    RN技术详细了解: RN环境的搭建: 1.           首先安装node.js 2.           安装homebrew(网上内容很多自己找,详细的我就不多说了) (1)   在home ...

  9. java service 安装

    sudo ln -s /var/services/video/video-live.jar /etc/init.d/live-service sudo chmod +x /var/services/v ...

  10. Oracle数据库表解锁语句

    --表解锁select sess.sid, sess.serial#, lo.oracle_username, lo.os_user_name, ao.object_name, lo.locked_m ...