[Tutor] problem with python3.5 headfirst python 2nd ed chpt 10 test drive example decorator issues

Peter Otten __peter__ at web.de
Fri Sep 29 14:19:24 EDT 2017


peter wrote:

> I am on chapter 10 of headfirst python second edition. got most of the
> prior codes to work but am stuck on this one. I will add the
> simple_webapp.py which is a decorator enabled  and checker.py which is
> the decorator. when I go into 127.0.0.1:5000 and enter I get the correct
> response. 127.0.0.1:5000/page1 gets me 'you are not logged in' also
> correct.
> 
> '127.0.0.1:5000/login' returns 'you are now logged in'  which is correct
> but '127.0.0.1:5000/page1' after that should return 'this is page 1' but
> instead returns 'you are not logged in'.
> 
> When I login to page 1 the 'session['logged_in'] = True' should still be
> true but apparently it has not been passed to 'check_logged_in'.
> 
> I am stumped and do not know how to proceed to figure this out.
> 
> Here are the codes
> 
> Also they are attached to this email. I am hoping someone can show me
> the errors of my ways. hopefully it is something simple but I have gone
> over it a lot and think the code is correct.

The best approach is usually to do something completely different, and than 
look at the code with fresh eyes. Or to ask someone else, of course...
 
> Thank you for your attention and help.

>  session['logged_in'] = True

>  if 'logged _in' in session:

It looks like an extra space slipped in here.



More information about the Tutor mailing list