python - Django decorator from middleware with different args per view function -
i have sso middleware in django project, need pass argument.
in views.py
file have different view functions decorated decorator_from_middleware_with_args
have different arguments:
sso_decorator = decorator_from_middleware_with_args(ssomiddleware) @sso_decorator(true): def index(): ... @sso_decorator(false): def view(): ...
and here middleware class:
class ssomiddleware: def __init__(self, some_arg=false): self.some_arg = some_arg def process_request(self, request): print self.some_arg
when access index view via url, output in console is:
some argument: false argument: true
i have 2 questions here:
why process_request function executed twice? why have different argument?
Comments
Post a Comment