The following code (pseudocode) in flask confused me a lot.
def IsIllegal(f):
@wraps(f)
def decorated(*args,**kwargs):
if True:
return error msg
else:
return f(*args,**kwargs)
return decorated
@IsIllegal
@app.route(..., methods = ['POST'] )
def func1():
data = flask.request.get_data()
print(data)
...
where function IsIllegal is used to check if the user is NOT logged in. What I found is that func1 always print the data even the user is not logged in. The return value of func1 is, as expected, stopped by the function IsIllegal. But I feel that it is not save because the statement in func1 is executed (the print). How can I understand this?