Skip to content Skip to sidebar Skip to footer

Required Login Using Decorator Using Gae Python. Passing Parameters?

I'm trying to make a required login decorator using python gae. import utils def login_required(func): def check_login(self, *args, **kw): user_cookie = self.request.c

Solution 1:

I believe the issue you're having is with variable scope. user_logged_in and username are local to your check_login and gets executed before returning the new render_with_login function to be executed afterwards.

I think your best bet might be passing your username and user_logged_in as keyword args to your render_with_login function by changing:

returnfunc(self, *args, **kwargs)

to

returnfunc(self, username=username, user_logged_in=user_logged_in, *args, **kwargs)

I'm not a python expert by the way so I'm not positive about the scoping part, but it's my best guess. It would be easy to test anyways.

Post a Comment for "Required Login Using Decorator Using Gae Python. Passing Parameters?"