Created
June 26, 2013 11:38
-
-
Save mortymacs/5866763 to your computer and use it in GitHub Desktop.
Simple python decorator.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
session = False | |
def login_required(fn): | |
def ok(input): | |
if(session == True): | |
data = "welcome dear %s" % input | |
else: | |
data = "you are not logged in" | |
return data | |
return ok | |
@login_required | |
def index(inputs): | |
return inputs | |
def login(): | |
global session | |
session = True | |
login() | |
print index("morteza") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment