标签:bbs com dap ati black rgs back inpu word
# Author: Imxcai
username, password = ‘xcai‘, "xcai1234"
def auth(auth_type):
def out_wrapper(func):
def wrapper(*args, **kwargs):
if auth_type == ‘local‘:
user = input("username:").strip()
passwd = input("password:").strip()
if user == username and password == passwd:
print("authentication success")
return func(*args, **kwargs)
else:
print("authentication fail")
elif auth_type == ‘ldap‘:
print("i am not use ldap")
return wrapper
return out_wrapper
def index():
print("welcome to index page")
@auth(auth_type=‘local‘)
def home(name):
print("welcome to home page", name)
@auth(auth_type=‘ldap‘)
def bbs():
print("welcome to bbs page")
index()
home(‘abc‘)
bbs()
标签:bbs com dap ati black rgs back inpu word
原文地址:http://www.cnblogs.com/imxcai/p/7599603.html