I am having chalice project and using that i am sending mails to the clients. Every client is associated with an organization. Till now i was using same template for all clients but now i need to make changes in the mail template at organization level like every organization demand different things in the mail for their users. Should i use factory design pattern in chalice for solving this problem if organizations are more than 50. I doubtful because for that i have write 50 different classes for each organization Or should I use decorator feature of python which can wrap every function as per the requirement. Please help me with this if you are having clear knowledge of Design pattern.
def userDecoratorMail(func): #passing method as first class function
def wrapperFunc(appdata):
if appdata["org_id"] == 5: #checking the condition with client id
return func(appdata)
return "Secondary Template" #return secondary templte.
return wrapperFunc
@userDecoratorMail
def mail(appdata): # Base method
return appdata #some mail function will get trigger with appdata information
dict1 = {"user_id":"123","username":"chandresh","org_id":5}
mail(dict1) # calling base method.
Aucun commentaire:
Enregistrer un commentaire