getattribute
属性访问拦截器
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的更多相关文章
- request中getParameter和getAttribute的区别
整理一下getParameter和getAttribute的区别和各自的使用范围. (1)HttpServletRequest类有setAttribute()方法,而没有setParameter()方 ...
- getAttribute、setAttribute、removeAttribute
1.函数语法 elementNode.attributes:属性返回包含被选节点属性的 NamedNodeMap. elementNode.getAttribute(name):方法通过名称获取属性的 ...
- request:getParameter getAttribute
转载自:http://www.cnblogs.com/shaohz2014/p/3804656.html 在浏览器地址输入,表示传入一个参数test,值为123 http://localhost:88 ...
- sizzle分析记录:getAttribute和getAttributeNode
部分IE游览器下无法通过getAttribute取值? <form name="aaron"> <input type="text" name ...
- request属性 request.getAttribute()
一.request.getParameter() 和request.getAttribute() 区别 (1)request.getParameter()取得是通过容器的实现来取得通过类似post,g ...
- request getParameter getAttribute
在浏览器地址输入,表示传入一个参数test,值为123 http://localhost:8888/Test/index.jsp?test=123 在index.jsp中尝试使用EL表达式取出,代码如 ...
- setAttribute,,,getAttribute,,,,
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- JQuery 1.8.3对IE9兼容问题getAttribute
jQuery1.8.3在IE9下attr报错问题 jQuery1.8.3在IE9中attr方法保存. 解决方案如下: r = e.getAttribute(n); 修改为: r = e.getAttr ...
- getattribute()与getparameter()的区别
1.它们取到的值不同.getAttribute取到的是对象(object),而getParameter取到的是String. 2.数据传递路劲不同.request.getParameter方法传递的数 ...
- 【JSP手记】--jsp里面session.getAttribute("×××")在java中的表示
JSP里面的 <%=session.getAttribute("×××")%> 与java等价于 request.getSession().get ...
随机推荐
- 在500jsp错误页面获取错误信息
自定义异常发生时的错误处理页面: 1) 只要定义page指示元素的errorPage属性就可以指定当前页面发生异常时应该交给哪个页面进行处理,例如:<%@page errorPage=" ...
- 单机器搭建 zk 集群
在一台机器上配置 2 节点的 zk 集群,zk1 和 zk2 的 serverid 分别为 1 和 2,本机 ip 是 192.168.40.1 zk1 相关配置: dataDir=E:/test/z ...
- centos 7 安装iptables防火墙
firewalle: 开启6379端口和16379端口 [root@localhost ~]# firewall-cmd --zone=public --add-port=6379/tcp --per ...
- .Netcore使用Session
1.使用Session(进程内) 在startup中添加方法 services.AddSession app.UseSession() services.AddDistributedMemoryCa ...
- 大雄的elk实践
目录 一.ElK环境搭建 1.1.elasticsearch 1..kibana 1..logstash二.elk实践 2.1 使用elk分析nginx日志 一.ElK环境搭建 1.1 elast ...
- 编译darknet出现libpng16.so.16:对‘inflateValidate@ZLIB_1.2.9’未定义的引用
cd /usr/lib/x86_64-linux-gnu sudo ln -s ~/anaconda/lib/libpng16.so.16 libpng16.so.16 sudo ldconfig## ...
- get 乱码解决方案
1.针对Post方式提交的请求如果出现乱码,可以每次在request解析数据时设置编码格式: request.setCharacterEncoding("utf-8"); 也可以使 ...
- 一般xcode报错
下面这图报找不到FMDtabaseQueue,其实是把文件拖入xcode的时候xcode没有把.m文件添加进工程路径 解决办法:build phases-> compile sources &q ...
- 说说VBA中的面向对象
对象是 Visual Basic 的结构基础,在 Visual Basic 中进行的所有操作几乎都与修改对象有关.Microsoft Word 的任何元素,如文档.表格.段落.书签.域等,都可用 Vi ...
- keil安装
安装准备: 一个keil安装程序,一个注册机 安装步骤.... 软件安装: 打开C51V901.EXE 安装程序 点击Next, 同意上述证书协议 重复点击Next,知道出现finish停下. 3个多 ...