Google App Engine: Difficulty with Users API (or maybe just a Python syntax problem)
Posted
by Rosarch
on Stack Overflow
See other posts from Stack Overflow
or by Rosarch
Published on 2010-04-07T18:53:02Z
Indexed on
2010/04/07
19:03 UTC
Read the original article
Hit count: 144
I have a simple GAE app that includes a login/logout link. This app is running on the dev server at the moment.
The base page handler gets the current user, and creates a login/logout url appropriately. It then puts this information into a _template_data
dictionary, for convenience of subclasses.
class BasePage(webapp.RequestHandler):
_user = users.get_current_user()
_login_logout_link = None
if _user:
_login_logout_link = users.create_logout_url('/')
else:
_login_logout_link = users.create_login_url('/')
_template_data = {}
_template_data['login_logout_link'] = _login_logout_link
_template_data['user'] = _user
def render(self, templateName, templateData):
path = os.path.join(os.path.dirname(__file__), 'Static/Templates/%s.html' % templateName)
self.response.out.write(template.render(path, templateData))
Here is one such subclass:
class MainPage(BasePage):
def get(self):
self.render('start', self._template_data)
The login/logout link is displayed fine, and going to the correct devserver login/logout page. However, it seems to have no effect - the server still seems to think the user is logged out. What am I doing wrong here?
© Stack Overflow or respective owner