#!/usr/bin/env python
class Processor:
def __init__(self, processor):
self.processor = processor
def isAllowSend(self, message, setChargeFlag):
pass
class WhildListProcessor(Processor):
def isAllowSend(self, message, setChargeFlag):
if message.sender in (1,2):
return True
if self.processor != None:
return self.isAllowSend(message, setChargeFlag)
class DateProcessor(Processor):
def isAllowSend(self, message, setChargeFlag):
if message.date > "20130101":
return False
if self.processor != None:
return self.isAllowSend(message, setChargeFlag)
class DefaltProcessor:
def isAllowSend(self, message, setChargeFlag):
setChargeFlag(message)
return True
def getProcessor():
return WhildListProcessor(DefaltProcessor(None))
class Message:
def __init__(self, sender, ):
self.sender = sender
self.isSend = False
self.isCharge = False
def setChargeFlag(message):
message.isCharge = True
def setSendFlag(message):
message.isSend = True
def run(self):
message = Message(10)
processor = getProcessor()
if (processor.isAllowSend(message, setChargeFlag)):
setSendFlag(message)