责任链模式
责任链模式:将能处理请求的对象连成一条链,并沿着这条链传递该请求,直到有一个对象处理请求为止,避免请求的发送者和接收者之间的耦合关系。
#encoding=utf-8
#
#by panda
#职责连模式
def printinfo(info):
print unicode(info, ‘utf-8’).encode(‘gbk’)
#抽象职责类
class manager():
successor = none
name = ”
def __init__(self, name):
self.name = name
def setsuccessor(self, successor):
self.successor = successor
def handlerequest(self, request):
pass
#具体职责类:经理
class commonmanager(manager):
def handlerequest(self, request):
if request.requesttype == ‘请假’ and request.number